glob2-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[glob2-devel] Glob2 and Lua


From: Stéphane Magnenat
Subject: [glob2-devel] Glob2 and Lua
Date: Sun, 28 Dec 2014 11:14:40 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0

Hello,

I have had a look at the source code of Lua today, and it seems the easiest scripting system I have seen to date to embed into Glob2. In particular: - It is easy to call co-routines from the host side, so that would fit very well our use case for scripting units, buildings and the map. - Although Lua 5.2 uses double as numbers by default, we can compile Lua to use integers for numbers (providing a small rewrite of the math library). - It is easy to remove some default libraries, so we can sandbox Lua inside Glob2 (and use things like the glob2 virtual file system for IO if we want, etc.) - We can serialize the entire lua_State* using the ERIS distribution of Lua [1].

With that in mind, we can imagine an architecture in which every unit, building and map has a Lua_state* (i.e. a full Lua VM) and a co-routine handling its behaviour. These would be loaded from a Lua source code file, so they would be very easy to change without having to know about (or recompile) the core C++ engine. In addition, it would force us to define a clean (and documented) interface about what is provided to the behaviour script. This will typically be a set of values and functions.

What do you think?

cheers,

Stéphane

[1] https://github.com/fnuecke/eris

--
http://stephane.magnenat.net



reply via email to

[Prev in Thread] Current Thread [Next in Thread]