我想创建一个类似的表格:
myTable = {
[0] = { ["a"] = 4, ["b"] = 2 },
[1] = { ["a"] = 13, ["b"] = 37 }
}
使用C API吗?
我的当前方法是
lua_createtable(L, 0, 2);
int c = lua_gettop(L);
lua_pushstring(L, "a");
lua_pushnumber(L, 4);
lua_settable(L, c);
lua_pushstring(L, "b");
lua_pushnumber(L, 2);
lua_settable(L, c);
在循环中创建内部表格。在此循环之前,我使用
lua_createtable(L, 2, 0);
int outertable = lua_gettop(L);
创建一个包含2个数字插槽的外部表格。
但是如何将内部表格保存到外部表格中?