我有 C++ 对象并且我有 Lua对象/表。 (还有 SWIG C++ 绑定(bind)。)
我需要做的是关联这两个对象,这样如果我说
CObject* o1 = getObject();
o1->Update();
它将执行等效的 Lua:
myluatable1.Update();
到目前为止,我可以想象 CObject::Update 将具有以下代码:
void CObject::Update(){
// Acquire table.
// ???
// Do the following operations on the table.
lua_getfield(L, -1, "Update");
lua_pcall(L, 0, 0, 0);
}
我将如何存储/设置要使用的 Lua 表,以及上面的 //???
中将包含哪些内容才能使 Update 调用起作用?
最佳答案
关于c++ - 在 C 中跟踪 Lua 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1973788/