lua-users home
lua-l archive

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

Newbie question....

We're trying to come up with an efficient way to handle our game objects
from lua.  For a given game object, we define a complete schema that
includes the engine data and the game extensions to that data.  So for
example, an Actor schema will have some core internal use variables and
some additional game specific variables (e.g. tank might have armor,
player might have health, etc.)  Currently, we stuff the engine's
internal variables into a C struct and the additional variables into a
lua table, then use lua bindings to call engine functions that operate
on the internal data and use lua directly to manipulate the lua tables.
So far so good.

At authoring time all of this is transparent to the designer.  They
simply create instances of actors and add new variables to them as they
need them.  When they export the game, we split the data and generate a
guid for each engine object and embed that in the engine data and then
create a lua table with the same name as the guid that also contains
elements to hold the additional variables.

My questions are:

1.  Is this a lame way to do this?  What are the other ways?  (either
implicitly or explicitly)
2.  If I have a guid of A123 (stored as a 4 byte int, not char) and I
create a lua table as A123 = {}, when I call from the engine into lua,
what do I need to pass lua (or configure before calling) so that a lua
funciton can receive the correct table to operate on?  I tried several
experiments passing in the A123 as a number and a string and it doesn't
work.  Do I need to pass the table itself?  How do I do that?

Thanks for the help.