- a lua function return two number
- c++ calls the lua function: foo
- I don't know whether it's needful to pop the return value of function foo(lua_pop(L,2);).
- please tell me how to do it and why. thanks very much.
part code like this:
// lua function
function foo(a, b)
return a+b, a-b;
end
// c++
lua_getglobal(L,"foo"); // push function
lua_pushnumber(L,1); // push argument 1
lua_pushnumber(L,2); // push argument 2
error=lua_pcall(L, 2, 2, 0);
if (!error) {
printf("return:%s\n",lua_tostring(L,-1));
printf("return:%s\n",lua_tostring(L,-2));
// is this needful
lua_pop(L,2);
}