lua-users home
lua-l archive

Creating a table through the API

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I'm trying to create a table equivalent to t = {1,2,3,4,5}
Sofar what I've come up with is:
 lua_newtable(L);
 lua_pushstring(L, PChar('1'));
 lua_pushnumber(L, 2);
 lua_settable(L, -3);
 lua_setglobal(L, PChar('t'));
It should create a table t = {2} but when I print the table contents it appears to be empty. Can anyone point me where I'm going wrong here?
Kind regards, Darius

AltStyle によって変換されたページ (->オリジナル) /