I want to create a table like
myTable = {
[0] = { ["a"] = 4, ["b"] = 2 },
[1] = { ["a"] = 13, ["b"] = 37 }
}
using the C API?
My current approach is
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);
to create the inner tables in a loop. Before, this loop, I use
lua_createtable(L, 2, 0);
int outertable = lua_gettop(L);
to create the outer table for 2 numeric slots.
But how can I save the inner tables to the outer table?
Aucun commentaire:
Enregistrer un commentaire