lua-users home
lua-l archive

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


C++:
    lua_newtable (L);
    lua_settable (L,1);
lua_Integer n = 6;
    lua_pushinteger (L, n);

Try something like this:

int arr[4] = { 5,100,-20,0 };
lua_newtable(L);              // table
for (i=0; i<4; i++) {
  lua_pushinteger(L, i+1);    // table,key
  lua_pushinteger(L, arr[i]); // table,key,value
  lua_settable(L,-3);         // table
}

... and read "Programming in Lua" (http://www.lua.org/pil/),
on-line and free :)

--
Shmuel