English 中文(简体)
Lua C AP: 删除用卢阿-新金属制成的元数据?
原标题:Lua C API: Delete metatable created with luaL_newmetatable?
  • 时间:2011-02-17 19:33:34
  •  标签:
  • lua
  • lua-api

如何删除由<代码>luaL_newmetatable(L,“foo” );创建的一张表<代码>foo,以便luaL_getmetatable(L,“foo” );将再次推动NIL的增值?

问题回答

无论你需要删除元件,都是可能的。 luaL_newmetatable(L,“foo”) 创立了一个表格,储存在Lua登记处,主要有“foo”

删除表格,在登记册中将“外地代码”“foo”列入nil。 C中的法典:

lua_pushnil(L);
lua_setfield(L, LUA_REGISTRYINDEX, "foo");

Lua的等效法:

debug.getregistry()["foo"] = nil




相关问题
Wrapping a Lua object for use in C++ with SWIG

Currently I know how to have C++ objects instantiated and passed around in Lua using SWIG bindings, what I need is the reverse. I am using Lua & C++ & SWIG. I have interfaces in C++ and ...

Can t lua_resume after async_wait?

I have some lua script that have some long running task like getting a web page so I make it yield then the C code handle get page job async, so the thread free to do other job and after a specify ...

How to remove a lua table entry by its key?

I have a lua table that I use as a hashmap, ie with string keys : local map = { foo = 1, bar = 2 } I would like to "pop" an element of this table identified by its key. There is a table.remove() ...

Lua plain string.gsub

I ve hit s small block with string parsing. I have a string like: footage/down/temp/cars_[100]_upper/cars_[100]_upper.exr and I m having difficulty using gsub to delete a portion of the string. ...

why do i get "attempt to call global require (a nil value)"?

I have 3 lua files, Init.lua, FreeCamera.lua and Camera.lua , init.lua calls require "Core.Camera.FreeCamera" Free Camera: module(...) require "Core.Camera.Camera" local M = {} FreeCamera = M M ...

热门标签