programming

lua introspection and interface : sep 15

what is this for? is this for serialization? is this going to make it more difficult
to bind things together because now you have two types of objects to bind? i guess it doesn't matter because c++ objects will be wrapped by lua objects, not the other way around.

basically you supply all of the gets and sets for the class as static members.

class Monkey
{

public:

float _numA;
float3 _vecA;

public:

Monkey()
{
_numA=0;
}

public:

virtual bool sendMessage(const char* message,char* returnBuf,int returnBufLen)
{
return _lua->exec(message,returnBuf,returnBufLen);
}

public: //-- lua getter/setter

static void get_numA(LuaState* L){..}
static void get_vecA(LuaState* L){..}

static void set_numA(LuaState* L){..}
static void set_vecA(LuaState* L){..}

static gbLua _lua;
};

when you want c++ to talk from one object to another, you can do it via a sendMessage interface which is not so bad to have inherited.

wait.. naming convention to the rescue. if each object lives in the lua globals with a unique name, then you can just call lua directly to get things done. that is how you talk between objects.

so you have a global lua context you can talk with. that still leaves the binding which can be done with a getter/setter. you don't have to keep a class variable because you can just store that in special lua classes too. the getter/setter stuff does not need to reside in the class either, though it probably should be in the header file for fast compiling.

so how does the whole flow work?

a level entity database is chosen to be loaded in.
an entitydatabase is also a lua object and all the entities are created as they are come across. the entities are just a flat list. to throw away a level you can just delete the entity database and bam.

wait. what is the value of having the entity database a lua object? why not have everything global and use a naming convention to access everything. it is easy enough to have them in a namespace table though. it still is just via naming convention. you can include that namespace name in all the bindings it doesn't matter.

entity.*
bitmap.*
font.*
gui.*
sound.*
music.*

so to start again with flow.

the entity database is created and its read is called. it reads a lua file that starts with a table named entity with contains a a comma separated list of entities. each entity has a unique name. when an entity is parsed, the object is created with its instance name as an argument and is registered with the entity database somehow.

one problem is pointers need to be resolved. this is a multi-pass process. when the object is saved, its raw pointer is saved as an extra entry called raw_pointer. anything pointing to anything else just uses that raw pointer. after everything is loaded in, all of the

the raw pointer is just saved as is. the raw

when everything control is from the c++ side.

ack. crap.