From bcf47bc67cf3e1c2f410a81e26ceab1bdab06b4a Mon Sep 17 00:00:00 2001 From: kwolekr Date: Wed, 5 Aug 2015 00:49:35 -0400 Subject: Improve Script CPP API diagnostics --- src/script/cpp_api/s_nodemeta.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'src/script/cpp_api/s_nodemeta.cpp') diff --git a/src/script/cpp_api/s_nodemeta.cpp b/src/script/cpp_api/s_nodemeta.cpp index 01eee337c..638750b0e 100644 --- a/src/script/cpp_api/s_nodemeta.cpp +++ b/src/script/cpp_api/s_nodemeta.cpp @@ -54,8 +54,7 @@ int ScriptApiNodemeta::nodemeta_inventory_AllowMove(v3s16 p, 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_metadata_inventory_move should" " return a number, guilty node: " + nodename); @@ -89,8 +88,7 @@ int ScriptApiNodemeta::nodemeta_inventory_AllowPut(v3s16 p, 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_metadata_inventory_put should" " return a number, guilty node: " + nodename); @@ -124,8 +122,7 @@ int ScriptApiNodemeta::nodemeta_inventory_AllowTake(v3s16 p, 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_metadata_inventory_take should" " return a number, guilty node: " + nodename); @@ -162,8 +159,7 @@ void ScriptApiNodemeta::nodemeta_inventory_OnMove(v3s16 p, 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 @@ -191,8 +187,7 @@ void ScriptApiNodemeta::nodemeta_inventory_OnPut(v3s16 p, 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 @@ -220,13 +215,14 @@ void ScriptApiNodemeta::nodemeta_inventory_OnTake(v3s16 p, 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)); } -ScriptApiNodemeta::ScriptApiNodemeta() { +ScriptApiNodemeta::ScriptApiNodemeta() +{ } -ScriptApiNodemeta::~ScriptApiNodemeta() { +ScriptApiNodemeta::~ScriptApiNodemeta() +{ } -- cgit v1.2.3