lua-users home
lua-l archive

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


In the code example I gave you the user script cannot pollute the global table because every global access is done in an intermediate table. The middle part that I tagged optionnal let the user scripts read the globals but write to the intermediate table. You should read the Lua manual and the PiL to get a global understanding of environment tables and metatables and what is possible to do with them. 
 
PS: That damned outlook sent my last mail before I wrote it (and again I can't properly quote). Here it is, sorry for the noise.

De : lua-bounces@bazar2.conectiva.com.br [mailto:lua-bounces@bazar2.conectiva.com.br] De la part de Zé Pedro
Envoyé : 22 janvier 2007 12:40
À : Lua list
Objet : Re: how to remove a value from the globals table

Both the replies have worked fine, thanks. But I suddenly realised that I had another problem. By default variables in Lua are global right? so if the users don't explicitly define their variables as local ones they'll be around for the execution of the next user script. Then I saw that there was a table were the globals are kept in the index LUA_GLOBALSINDEX. Can I made a copy of this table before execute and then after replace it by the copy I made before right? The thing is that I print lua_objlen(pLuaState,LUA_GLOBALSINDEX) (it should print the number of globals or at least a number other than zero right?) and it prints zero. Is this the correct behaviour? Another thing, how can I copy the table to specified index? lua_pushvalue(L, LUA_GLOBALSINDEX) copy it to the top of the stack how can I move it to position COPY_GLOBALSINDEX?

thanks,
José Tavares