[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Passing arrays from C++ to LUA
- From: Shmuel Zeigerman <shmuz@...>
- Date: Mon, 27 Aug 2007 18:26:59 +0200
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