lua-users home
lua-l archive

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


I have still have yet to figure out how to have different Lua scripts
control different subsystems of a game engine I'm interested in writing
(though I'll admit I haven't had the time to give it a whole lot of thought,
and I am definitely a Lua-newbie).

In the game there will be different C++ objects representing different
systems, which will call Lua functions in response to events that occur in
the game world. Each script should probably only be able to access the
member functions of one particular object, since many objects will be of the
same class but will need to have their own unique behaviors. For example,
each enemy in the game might be an instance of a Sprite class, and its
scripts will define its unique movement and behavior by calling manipulating
member variables through mutator functions, etc. It seems that the only way
to do this is by using multiple Lua states, one for each subsystem. There
could potentially be dozens of sprites in a level (each requiring its own
Lua state), not to mention sectors and other objects that would also be
script-driven. Would having this many states slow things down in a big way?
If so, is there another way to attack the problem?

Thanks,
Tim
-- 
Tim Conkling
Vaporware Software
<http://members.mint.net/conkling>