lua-users home
lua-l archive

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


----- Original Message -----
> E.g. you might end up passing a lot of variables to your Lua scripts every
time you call them - variables that could be
> kept in Lua itself. And you'd need a callback to C every time your scripts
need to access a complex data structure.

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..

Example:

lua_dofile("source file with all functions and initialization code");
while(!Quit)
{
  lua_callfunction(lua_getglobal("primary script function");
  RenderDisplayAndOtherCstuff();
}

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
it up to several calls to lua_callfunction ... One for Bots, one for
usercontrol one for environment control etc...... the lua linehook or
callhook could be used as a timer function that would about a call if a
sertain time is consumed ...

/Erik