lua-users home
lua-l archive

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


Hi,
May be this can help you. You can do this from C code too of course.

meta={}
meta.__newindex = function(t,v,value) print("Avoid variable
modification of "..v.." !!!") end
myvar = 6
print(myvar)
-- do the magic
setmetatable(_G,meta)
myval=5
print(myvar)

Cheers,
   Jose L.

On 8/31/06, Christopher Lux <christopherlux@gmail.com> wrote:
Hi,
i looking for a way to to achieve read only variables at least for my own
defined global variables. I found a way for lua 4.0 with lua_settagmethod
but this way does not work anymore with lua 5.x. So is there a way to get
this kind of functionality?

-chris
--
Christopher Lux |
                 | Bauhaus University Weimar
                 | Faculty of Media - Virtual Reality Systems Group