lua-users home
lua-l archive

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


Hi everybody,
 
This is my first message to the list so I would like to say hi to anybody out there.
 
I have decided to post to the list because I have some problems designing the scripting infrastructure for my game (it is obvious I´m usign lua).
 
I will explain first how things are setup at the moment:
 
1) All is about how to manage entities in my game (monsters, player, etc...).
2) My classes will be splited in two, a c++ super class, and a data in lua with behaviours (logic for entities) for every entity (in a table or something else).
3) the c++ class is just a proxy class, that receives events and call lua events for the entity (just a bridge).
4) Ok, now the real problem, how to setup things on lua to hold entity instance data and behaviours and how to access them:
    
    I have been thinking I could have a master state with substates (one per entity instance). The substates wil be kept by teh c++ part
    of the monster class to allow me easy access to its properties without indexing.
    In the master state I should be having an entity array holding all created entities references to allow an entity (substate), access
    another entity data for logic or whatever. In the master state there will exist all entities blueprints too, that will be loaded form a dir
    when game is inited with lua_loadfile or whatever. This blueprints are used to really instantiate the monster in lua side.
 
    To create an entity, I will be calling my entity manager in c++ that will instantiate the c++ part of the entity (the generic class). This
    will create a new lua_state and will keep it in a member of the class, this state will be the enviroment for the lua part of this entity.
    Next I should be intancing the lua part of the blueprint in this state, and everything will be setup, and logic on this instance can be ran.
 
So, I need someone to give me a good of advice about this "mental" design, to tell me if I can manage to do things as I´ve being described,
becasue I don´t have too much experience with lua. I have read the docs, but I need more experience on it.
 
 
Thanks in advance,
HexDump.
   
 
   
   


Express yourself instantly with MSN Messenger! MSN Messenger