I'm trying to give a scripting ability to my component system. Of couse each component has a field "parent" which holds access to the parent Actor. I can write the code so I can access my C++ methods from Lua, but I got stuck when I want to return custom userdata, like actor. I have a method getParent(), and I want to return the Actor userdata, so I can write Lua code like this:
parent = getParent()
parent.<some method>
How can I achieve this? With lightuserdata? Or when getParent get called, create a new userdata, and point that pointer to the original one?