luaL_refint luaL_ref (lua_State *L, int t);
Creates and returns a reference,
in the table at index t,
for the object at the top of the stack (and pops the object).
A reference is a unique integer key.
As long as you do not manually add integer keys into table t,
luaL_ref ensures the uniqueness of the key it returns.
You can retrieve an object referred by reference r
by calling lua_rawgeti(L, t, r).
Function luaL_unref frees a reference and its associated object.
If the object at the top of the stack is nil,
luaL_ref returns the constant LUA_REFNIL.
The constant LUA_NOREF is guaranteed to be different
from any reference returned by luaL_ref.