#include <eventinterpreter.h>
Public Member Functions | |
EventInterpreter (World &world, const char *file) | |
updates static world pointer, and loads a lua script | |
~EventInterpreter () | |
Disengages lua. | |
void | Function (const char *function) |
calls one of the script functions | |
Private Attributes | |
lua_State * | l |
Lua State Machine. | |
Static Private Attributes | |
World * | currworld = 0 |
Pointer to current world instance. |
EventInterpreter uses lua to parse event scripts, which script the game. The scripts interface with the game via static functions inside this class (declaration register.h and definition in function.h using heavy macroing), which themselves interface with the engine using the static World pointer. This is because of a lua limitation (well C/C++ interface problem). To register functions with lua, they have to be called without references, and therefore to interface with the engine a static World pointer is needed. Basically this is a gateway between game scripts, and the game engine. The scripts should have 3 functions - init, proc and kill. init and kill are used when the script is loaded and unloaded, and proc is called every so often (i.e once per game loop), so that the script can test and interact with the game.
|
updates static world pointer, and loads a lua script
|
|
Disengages lua.
|
|
calls one of the script functions
|
|
Pointer to current world instance.
|
|
Lua State Machine.
|