|
From: | Kai Antweiler |
Subject: | Re: [glob2-devel] Glob2 and Lua |
Date: | Tue, 13 Jan 2015 13:58:25 +0100 |
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
_______________________________________________
glob2-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/glob2-devel
[Prev in Thread] | Current Thread | [Next in Thread] |