1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Handle LuaErrors in Lua -> C++ calls on LuaJIT

This commit is contained in:
ShadowNinja 2013-12-18 16:35:55 -05:00
parent 38d112033b
commit 49cec3f782
18 changed files with 113 additions and 134 deletions

View file

@ -54,7 +54,7 @@ int ScriptApiDetached::detached_inventory_AllowMove(
if(lua_pcall(L, 7, 1, errorhandler))
scriptError();
if(!lua_isnumber(L, -1))
throw LuaError(L, "allow_move should return a number");
throw LuaError(NULL, "allow_move should return a number");
int ret = luaL_checkinteger(L, -1);
lua_pop(L, 2); // Pop integer and error handler
return ret;
@ -86,7 +86,7 @@ int ScriptApiDetached::detached_inventory_AllowPut(
if(lua_pcall(L, 5, 1, errorhandler))
scriptError();
if(!lua_isnumber(L, -1))
throw LuaError(L, "allow_put should return a number");
throw LuaError(NULL, "allow_put should return a number");
int ret = luaL_checkinteger(L, -1);
lua_pop(L, 2); // Pop integer and error handler
return ret;
@ -118,7 +118,7 @@ int ScriptApiDetached::detached_inventory_AllowTake(
if(lua_pcall(L, 5, 1, errorhandler))
scriptError();
if(!lua_isnumber(L, -1))
throw LuaError(L, "allow_take should return a number");
throw LuaError(NULL, "allow_take should return a number");
int ret = luaL_checkinteger(L, -1);
lua_pop(L, 2); // Pop integer and error handler
return ret;