lua-users home
lua-l archive

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


I have a variable, say p, of type user data on which I need to eumulate
getting/setting of values as though the user data were a table:

That is,

p.x = 4 (catch this access to x and handle as appropriate)
q = p.x (catch this access and return the value of x)

I've sadly discovered that if my metatable for userdata p (heavy, not light)
has a __newindex method, it is NOT called when attempting to access x (and
other values).  

Instead, lua complains that I cannot index userdata.  Is there an "in lua"
way of intercepting the table-like access calls to userdata?

If not, I may need to patch lua itself and where it detects the error,
instead route it to get/set the variables as appropriate, etc...