lua-users home
lua-l archive

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


Metamethod (__newindex in this example) is only called when:
* 'a' is nil 
* 'a' is a 'field' in a table (if its a global variable, it resides in _G - and thus you want to attach a metatable to _G - global enviroment)

http://pgl.yoyo.org/luai/i/lua_rawset This one does not call metamethods
http://pgl.yoyo.org/luai/i/lua_settable This one does.

2011/4/20 Marc Balmer <marc@msys.ch>
Does the Lua C part call a metatable method when it produces a value of
a variable?

i.e, if I have a userdata value 'n', can I intercept somehow the operation

a = n

?  At the moment, this assigns the string 'n' to a.




--
Łukasz Gruner