lua-users home
lua-l archive

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


i am working on a 3d fps engine and i am using LUA for engine initializtion, model/map loading, NPC scripting and fro cutscenes......
i am facing a problem with lua ....... and i'm not really sure wats the cause ......
the thing is that i created a  long cutscene in which various maps were being loaded as well as a large number of models ....... and many global variables were being created using :
lua_pushstring( L, value);

lua_setglobal( L, varName);

i have kept the scripting logic very simple and currenty i am using only ifelse checks to control the cutscene ....... (i know that's not good programming .... but ...) now the problem that i was facing was that i set up a global variable late in the script ...... and then check it in a if check:

if corpse4_state == "CHECK_DEMO_STATE" then

now even though the call to lua to setup the global variable with the specified value was being made ..... this check was never true ..... i just cudn't figure wat the problem was (i don't know much lua) ....... then i thought that maybe there was a problem with the size of the stack of LUA which is used to exchange variables with C++ ...... so i reset the stack using:

lua_settop(m_pLUAState, 0);

before setting this particular variable ....... but that didn't help either ...... then finally i removed code for adding some models ...... and then it worked correctly ...... i don't know wat why it did ...... ? is there some memory related problem or is there something that i am doing ...... need help with  this ...... hope that i have expressed myself clearly .....


Do you Yahoo!?
The New Yahoo! Shopping - with improved product search