Passing Multiple Arrays (tables) From C to Lua

Use all the fxcodebase indicator in your application!

Moderator: admin

Passing Multiple Arrays (tables) From C to Lua

Postby Kyle.Gilbertson » Tue Apr 12, 2016 12:52 pm

I have a C function that returns two lists to Lua like this:

lua_checkstack(L, m); // where m is the combined size of the two arrays
for (i=1; i <= idx1; i++) {
lua_pushnumber(L, List1[i - 1]);
lua_rawseti(L, -2, i);
for (j=1; j <= idx2; j++) {
lua_pushnumber(L, List2[j - 1]);
lua_rawseti(L, -2, j);
return 2;

It seems to work, but not always. Is something missing here? This is what the call looks like in Lua:
List1, List2 = Cfunction(source, period);

It seems like List2 always gets populated, but List1 doesn't. Is there a better way to do this?
Posts: 14
Joined: Thu Feb 25, 2016 3:06 pm

Return to C++/.NET API

Who is online

Users browsing this forum: No registered users and 1 guest