lua-users home
lua-l archive

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


In our game application, it is possible for hundreds of game entities to be
running Lua scripts.  (Well, they're yield()ed 99.999% of the time!)  I
chose the course of creating a separate "thread" for each entity that uses a
script.  I believe this has less overhead (somebody correct me if I'm
wrong.)  It also has the benefit of allowing threads to communicate with
each other.

Additionally, you don't need to glue all your exposed functions separately
for each thread.  The thread has access to all the functions and libraries
of the state to which it belongs.

So far... no troubles with this method.

-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br]On Behalf Of Jeff Williams
Sent: Thursday, August 14, 2003 10:17 AM
To: lua@bazar2.conectiva.com.br
Subject: "Proper" way to use lua

I am adding scripting to my program using lua.  I am curious if my method is
in line with the general philosophy behind lua or if I am doing things
completely the wrong way.

For each instance of a class in my program, I create a lua state for the
instance (it is a member var) and then I register funcs with that lua state.

Is this the way I should do it?  Or should there only be one lua state in
the entire program and all my clases share that state?

I guess ultimately my question is more like:

Is lua designed to have hundreds of open states? or just a few?

Jeff