I have a method called GetParameter in C. And I want to use it from Lua. This method will again return some values ββin Lua.
The way Im constructs a table in C is the most common way:
lua_newtable(L);
for (int i = 0; i < parameters; i++)
{
lua_pushnumber(L,i);
lua_pushstring(L,myParameter);
lua_settable(L,-3);
}
In all the examples I saw, after that you should set the result table with lua setGlobal:
//set name for the result
lua_setglobal(ptLuaState, "resultTable");
With this method, I can access the result table in lua, for example:
GetParameter("V111","V111Parameter")
printTable(resultTable);
Doing it all goes well, but is there any other way to do this without using setglobal? I tried to do something like:
local mytable=GetParameter("V111","V111Parameter");
but does not work. Are global variables better? How can I get a result table without creating setglobal?
early!
source
share