summaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_inventory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/cpp_api/s_inventory.cpp')
-rw-r--r--src/script/cpp_api/s_inventory.cpp18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/script/cpp_api/s_inventory.cpp b/src/script/cpp_api/s_inventory.cpp
index 422faf150..c8c90fd8f 100644
--- a/src/script/cpp_api/s_inventory.cpp
+++ b/src/script/cpp_api/s_inventory.cpp
@@ -48,8 +48,7 @@ int ScriptApiDetached::detached_inventory_AllowMove(
lua_pushinteger(L, to_index + 1); // to_index
lua_pushinteger(L, count); // count
objectrefGetOrCreate(L, player); // player
- if (lua_pcall(L, 7, 1, m_errorhandler))
- scriptError();
+ PCALL_RES(lua_pcall(L, 7, 1, m_errorhandler));
if(!lua_isnumber(L, -1))
throw LuaError("allow_move should return a number. name=" + name);
int ret = luaL_checkinteger(L, -1);
@@ -77,8 +76,7 @@ int ScriptApiDetached::detached_inventory_AllowPut(
lua_pushinteger(L, index + 1); // index
LuaItemStack::create(L, stack); // stack
objectrefGetOrCreate(L, player); // player
- if (lua_pcall(L, 5, 1, m_errorhandler))
- scriptError();
+ PCALL_RES(lua_pcall(L, 5, 1, m_errorhandler));
if (!lua_isnumber(L, -1))
throw LuaError("allow_put should return a number. name=" + name);
int ret = luaL_checkinteger(L, -1);
@@ -106,8 +104,7 @@ int ScriptApiDetached::detached_inventory_AllowTake(
lua_pushinteger(L, index + 1); // index
LuaItemStack::create(L, stack); // stack
objectrefGetOrCreate(L, player); // player
- if (lua_pcall(L, 5, 1, m_errorhandler))
- scriptError();
+ PCALL_RES(lua_pcall(L, 5, 1, m_errorhandler));
if (!lua_isnumber(L, -1))
throw LuaError("allow_take should return a number. name=" + name);
int ret = luaL_checkinteger(L, -1);
@@ -139,8 +136,7 @@ void ScriptApiDetached::detached_inventory_OnMove(
lua_pushinteger(L, to_index + 1); // to_index
lua_pushinteger(L, count); // count
objectrefGetOrCreate(L, player); // player
- if (lua_pcall(L, 7, 0, m_errorhandler))
- scriptError();
+ PCALL_RES(lua_pcall(L, 7, 0, m_errorhandler));
}
// Report put items
@@ -164,8 +160,7 @@ void ScriptApiDetached::detached_inventory_OnPut(
lua_pushinteger(L, index + 1); // index
LuaItemStack::create(L, stack); // stack
objectrefGetOrCreate(L, player); // player
- if (lua_pcall(L, 5, 0, m_errorhandler))
- scriptError();
+ PCALL_RES(lua_pcall(L, 5, 0, m_errorhandler));
}
// Report taken items
@@ -189,8 +184,7 @@ void ScriptApiDetached::detached_inventory_OnTake(
lua_pushinteger(L, index + 1); // index
LuaItemStack::create(L, stack); // stack
objectrefGetOrCreate(L, player); // player
- if (lua_pcall(L, 5, 0, m_errorhandler))
- scriptError();
+ PCALL_RES(lua_pcall(L, 5, 0, m_errorhandler));
}
// Retrieves core.detached_inventories[name][callbackname]