|
Answering one of your questions: Use LUA_ENVIRONINDEX rather than the LUA_REGISTRYINDEX, see liolib.c for an example of its usage. And I think this recent quote from Rici Lake applies:
The simplest way is to keep a weak-valued table whose keys are lightuserdata (the pointer to the c structure) and whose values are the equivalent userdata object (containing the boxed pointer).
db