lua-users home
lua-l archive

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


On Friday, September 19, 2003, at 09:02  AM, Paul Tankard wrote:

have a main luavm, register all functions to it, then for each entity have a lua_newthread and do a lua_loadbuffer to the newthread with that particular script... now my head started melting when I thought of the calling process to the Lua script, I mean if I had a few threads each using a script which
 contained a function of the same name, say initialise, could I do a
lua_getglobal in that particular newthread for "initialise" then a lua_call
 and it would call the corrects scripts function, or does it get set
globally-globally so any script that has a function named the same will override the previous declaration like you would do function=nil to remove it ? this is obviously not the ideal way to do this.. especially if I have
 lots of entities that share the same script as it's using unnecessary
 overhead, but it would work ;)


namespaces.  enough said :).


secondly I could have functions defined in tables then creating an object and using self everywhere this would make sure I don't have repeated chunks of script code and make it more c++ class orientated, but the problem is creating the actual object from C/C++, I mean would I just purge all scripts I needed into one script file then do lua_loadbuffer to the main lua state,
 and then for each entity do something like lua_dostring("entity1 =
createentity:new("blah")); and get the function from the table of entity1
 and call that etc.

once again, just use namespaces to differentiate between your different objects.



-----

Michael Bernstein

"Until they become conscious they will never rebel, and until after they have rebelled they cannot become conscious"
--George Orwell, 1984




-----

Michael Bernstein

"Until they become conscious they will never rebel, and until after they have rebelled they cannot become conscious"
--George Orwell, 1984