lua-users home
lua-l archive

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


Hi.

I have tried implementing the same thing for a game engine. There 
also has been many threads about this subject in the past. Basicaly 
there is 2 approaches. One is to use co-routines and seperate the 
global and "thread" specific components of a Lua state. The other is 
to make Lua non-recursive (which will probably be implemented in 
Lua's next version).

I have posted some code snippits from my engine a few months ago and 
there has been sevral discussions about the subject so i suggest 
searching a few months back in the mailing list archives (or use 
www.egroups.com to do a search).

If you have aditional questions, don't hesitate to ask me.

Sebastien St-Laurent
Software Engineer, Z-Axis ltd.
sebby@velocityhsi.com


> 
>   Hi !!! I'm new on the list. My name's David. I'm trying to
>   embbed LUA 4.0 on my game engine and I've got a problem:
>   I need to run many scripts at the same time concurrently on
>   the same lua_state. This is so 'cause I register many functions
>   that would act as an API interface from LUA scripts to my engine.
>   The problem is that Lua seems not to support concurrent access
>   to states. Is this true ?  Is there any way to implement this ?
> 
>   Since now I'm creating a new state for each script. Then I
>   register the API functions on EVERY state, and launch the
>   script. As I create a new state for every script running, I
>   have to register ALL the API functions (near 300) for each
>   script run and I can't use global variables. Loosing global
>   variables are not a problem, but I don't like to register
>   the functions each time.
> 
>   Any Idea ? Thax 8)