Greetings. I work with the LUA script and C ++. The essence of the problem is that the data from the Lua script does not fall into the stack, or C ++ does not work correctly with the stack. In more detail, here is the script running on the LUA machine:
require("QluaConnector"); is_run=true; function main() while is_run == true do for i = 1, 3, 1 do -- print(tostring(i)); -- такой вывод на экран срабатывает верно QluaConnector.StartSendData(i); -- а этот уже нет sleep(1000); end; end end; The only thing I need to do is consistently push the stack and read three digits from it: 1, 2, 3.
C ++ code:
static int forLua_StartDataGet(lua_State *L) { while (true) { int value = lua_tonumber(L, 1); lua_pop(L,-1); Sleep(1000); return(value ); } } For the first time, the method does return 1, but instead of 2 and 3 it is already zero. If instead of lua_tonumber you lua_tonumber see the number of items in the lua_gettop stack lua_gettop then 1 function returns 1 and the second and further ones 0. I suspect that there is an error in the script or in C ++, help me figure it out.