// create a new LuaObject using the given state and stack index. func NewLuaObject(L *lua.State, idx int) *LuaObject { tp := L.LTypename(idx) L.PushValue(idx) ref := L.Ref(lua.LUA_REGISTRYINDEX) return &LuaObject{L, ref, tp} }