summaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_inventory.cpp
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2015-08-05 00:49:35 -0400
committerkwolekr <kwolekr@minetest.net>2015-08-05 21:13:03 -0400
commitbcf47bc67cf3e1c2f410a81e26ceab1bdab06b4a (patch)
tree11bd99b70ceb33175d7883cea4ab287cc5b09175 /src/script/cpp_api/s_inventory.cpp
parent3183d5a4038f16b5b4cbcfd0dac5f8d458bf8ba2 (diff)
downloadminetest-bcf47bc67cf3e1c2f410a81e26ceab1bdab06b4a.tar.gz
minetest-bcf47bc67cf3e1c2f410a81e26ceab1bdab06b4a.tar.bz2
minetest-bcf47bc67cf3e1c2f410a81e26ceab1bdab06b4a.zip
Improve Script CPP API diagnostics
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]