[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Saving the lua state
- From: "Luc Van den Borre" <luc@...>
- Date: Sat, 29 Jul 2000 23:04:57 +0200
| But the global variables stays in the state even if your program exsts... My
| suggestion is to use lua_callfunction from your primary C loop ... All the
| global variables will still work between calls..
| lua_dofile("source file with all functions and initialization code");
| lua_callfunction(lua_getglobal("primary script function");
| This is my suggestion to an effective Lua game engine.. The only problem is
| that the call to Lua must not take to much time.. On way could be to split
The way I've handled it is that each Lua script is basically an event handler. At startup each script registers its
'interest' in a number of events. When these occur (in the C part of the code), the script gets called, and the event
gets handled (or not) by the script. Typically it spits out some text and sets some state variables - nothing very time
consuming, and no loops to get out of control.
For example, a script can tell the C engine it wants to be notified of an EVENT_COLLISION happening on a certain object.
Then, when that object (e.g. a switch) gets hit by something, the script handles it.