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

Improve Script CPP API diagnostics

This commit is contained in:
kwolekr 2015-08-05 00:49:35 -04:00
parent 3183d5a403
commit bcf47bc67c
16 changed files with 129 additions and 107 deletions

View file

@ -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()
{
}