lua api - Lua C API: Delete metatable created with luaL_newmetatable? -
how can delete metatable foo
created lual_newmetatable( l, "foo" );
, lual_getmetatable( l, "foo" );
push nil value again?
whatever reason may have delete metatable, possible. lual_newmetatable(l, "foo")
creates table, stored in lua registry key "foo"
.
to delete table, set field "foo"
in registry nil
. code in c:
lua_pushnil(l); lua_setfield(l, lua_registryindex, "foo");
equivalent code in lua:
debug.getregistry()["foo"] = nil
Comments
Post a Comment