lua-users home
lua-l archive

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

> Xmilia Hermit <> said
> Instead of using the current Lua state with the timer the main Lua state should call the callback.

( sorry, missed your answer before, got caught in my spam net )

Thanks, this fixed the problem. Is it correct to always use the lua_State* when it's supplied as the argument to a callback ( module methods, metatable methods, _gc, etc ) and to always use the 'base' lua when calling into Lua from outside code ( ie my callback function )?

An example which allows the user to create a timer userdata object-  

Timer.New() - returns userdata and assigns metatable. Use supplied lua_State?
timer:Start() - metatable function to start timer. Use supplied lua_State?
timer:_gc - metatable garbage collection. Use supplied lua_State?
timer->callback() - external call back into Lua