What I want to do is this:
object.foo = "bar"
print(object.foo)
where “object” is a userdata.
I’ve been googling for a while (using the keyword __newindex and lua_rawset) but I can’t any examples that do what I want it to do.
I want to do this in with the lua api in c++
Let us write this in Lua code so that we can make quick experiments with the code
If you work with userdata you probably want to do the above using the C API. However the Lua code should make it clear extactly which steps are necessary. (The
newproxy(..)function simply creates a dummy userdata from Lua.)