lua-users home
lua-l archive

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


On Wed, Apr 20, 2011 at 10:09 AM, Marc Balmer <marc@msys.ch> wrote:
> 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.
>
>

Not in the general case - there is no way to intercept it for local
variables. If you only care about global variables, you could set a
metatable on the globals table and intercept access the same way you
would for any other table, using __index and __newindex metamethods.

-Duncan