In addition to Timβs answer, you can also go to bright user data. You are not getting a copy of your data on the Lua stack, all you click on Lua is a pointer.
Lua does not understand what is in this pointer, regardless of whether it points to real memory or how to access any objects in this pointer, so you will have to handle all this yourself on C. I usually send a pointer to an element in list, so if there is a risk that the record has been removed from the list, I first iterate over the list to check the pointer (not a big deal if your lists are short). To access the elements inside a pointer in Lua, you need to write get / set functions in C that you can call from Lua.
To get started, here are the entries when clicking and retrieving lightuserdata:
source share