lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello,

I was wondering why my application doesn't get the correct values from the stack with this function under a Release build (it does work under Debug ...):


lua_register(luaVm, "askNumber", &LuaExports::askNumber);


int LuaExports::askNumber(lua_State *luaVm) {
    getNpc(luaVm)->sendGetNumber(lua_tointeger(luaVm, -3), lua_tointeger(luaVm, -2), lua_tointeger(luaVm, -1));
    return lua_yield(luaVm, 1);
}



I call the function in a Lua file with this:

askNumber(0, 0, 0);


But it gives me these results:
getNpc(luaVm)->sendGetNumber(0, 0, 1);

O.o... Sometimes the values are switched too...
Using the following code works perfectly:

int LuaExports::askNumber(lua_State *luaVm) {
    getNpc(luaVm)->sendGetNumber(lua_tointeger(luaVm, 1), lua_tointeger(luaVm, 2), lua_tointeger(luaVm, 3));
    return lua_yield(luaVm, 1);
}


So I want to know what the correct (best?) way is to get a value from the stack?

Thanks in advance.


De nieuwste Internet Explorer: snel, eenvoudig en veilig. Download nu!