|
Lee Smith wrote:
That seems to work, until I try to create another table at index 2: (append) tableIndex++; lua_pushnumber(L, tableIndex); lua_newtable(L); // push 1 lua_pushstring(L, "item3"); // push 1 lua_pushstring(L, "value (item 3)"); // push 1 lua_settable(L, -3); // pop 2 lua_pushstring(L, "item4"); // push 1 lua_pushstring(L, "value (item 4)"); // push 1 lua_settable(L, -3); // pop 2 lua_pushvalue(L, -1); // push 1 lua_setglobal(L, "3rdtable"); // pop 1
Just move the instruction << lua_setglobal(L, "testtable"); >> to the end, becoming:
lua_pushvalue(L, -1); // push 1 lua_setglobal(L, "3rdtable"); // pop 1 lua_setglobal(L, "testtable"); Don't forget to _move_ it, not copy. --rb