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:
parent
3183d5a403
commit
bcf47bc67c
16 changed files with 129 additions and 107 deletions
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue