lua-users home
lua-l archive

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


I've seen a similar question already answered in the list but I'm not sure it applies to my problem.
In my program I'm executing lua code made by users and I have no control over it. What I'm doing now is setting the variables the code needs by doing:
                     lua_pushinteger(pLuaState, (int)atoi(value.c_str()));
                     lua_setglobal(pLuaState, name.c_str());

and then executing the script doing:
                     luaL_dostring (pLuaState, script.c_str())

the thing is that the script has no functions or anything, just calls to methods and declaration of variables. Once a script is executed the variables should be cleared but this must be made in C after the luaL_dostring call. Is there any way to do this or do I have to create a new LuaState for each time I execute a script?

thanks,
José Tavares

--
Believe nothing, no matter where you read it, or who said it,
no matter if I have said it, unless it agrees with your own reason
and your common sense.
- Buda

Para quê ter olhos azuis, se a Natureza deixa os meus  vermelhos?
- Bob Marley

"Don't try to use what you learn from Buddhism to be a Buddhist;
use it to be a better whatever-you-already-are."
- His Holiness the 14th Dalai Lama

Idealism is what precedes experience; cynicism is what follows.
  - David T. Wolf

"Please don't download, because I want to get a pool in my second home."
  - Kanye West