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
|
@ -106,8 +106,7 @@ bool ScriptApiNode::node_on_punch(v3s16 p, MapNode node,
|
|||
pushnode(L, node, ndef);
|
||||
objectrefGetOrCreate(L, puncher);
|
||||
pushPointedThing(pointed);
|
||||
if (lua_pcall(L, 4, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 4, 0, m_errorhandler));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -126,8 +125,7 @@ bool ScriptApiNode::node_on_dig(v3s16 p, MapNode node,
|
|||
push_v3s16(L, p);
|
||||
pushnode(L, node, ndef);
|
||||
objectrefGetOrCreate(L, digger);
|
||||
if (lua_pcall(L, 3, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 3, 0, m_errorhandler));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -143,8 +141,7 @@ void ScriptApiNode::node_on_construct(v3s16 p, MapNode node)
|
|||
|
||||
// Call function
|
||||
push_v3s16(L, p);
|
||||
if (lua_pcall(L, 1, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 1, 0, m_errorhandler));
|
||||
}
|
||||
|
||||
void ScriptApiNode::node_on_destruct(v3s16 p, MapNode node)
|
||||
|
@ -159,8 +156,7 @@ void ScriptApiNode::node_on_destruct(v3s16 p, MapNode node)
|
|||
|
||||
// Call function
|
||||
push_v3s16(L, p);
|
||||
if (lua_pcall(L, 1, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 1, 0, m_errorhandler));
|
||||
}
|
||||
|
||||
void ScriptApiNode::node_after_destruct(v3s16 p, MapNode node)
|
||||
|
@ -176,8 +172,7 @@ void ScriptApiNode::node_after_destruct(v3s16 p, MapNode node)
|
|||
// Call function
|
||||
push_v3s16(L, p);
|
||||
pushnode(L, node, ndef);
|
||||
if (lua_pcall(L, 2, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 2, 0, m_errorhandler));
|
||||
}
|
||||
|
||||
bool ScriptApiNode::node_on_timer(v3s16 p, MapNode node, f32 dtime)
|
||||
|
@ -193,8 +188,7 @@ bool ScriptApiNode::node_on_timer(v3s16 p, MapNode node, f32 dtime)
|
|||
// Call function
|
||||
push_v3s16(L, p);
|
||||
lua_pushnumber(L,dtime);
|
||||
if (lua_pcall(L, 2, 1, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 2, 1, m_errorhandler));
|
||||
return (bool) lua_isboolean(L, -1) && (bool) lua_toboolean(L, -1) == true;
|
||||
}
|
||||
|
||||
|
@ -229,8 +223,7 @@ void ScriptApiNode::node_on_receive_fields(v3s16 p,
|
|||
lua_settable(L, -3);
|
||||
}
|
||||
objectrefGetOrCreate(L, sender); // player
|
||||
if (lua_pcall(L, 4, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 4, 0, m_errorhandler));
|
||||
}
|
||||
|
||||
void ScriptApiNode::node_falling_update(v3s16 p)
|
||||
|
@ -239,8 +232,7 @@ void ScriptApiNode::node_falling_update(v3s16 p)
|
|||
|
||||
lua_getglobal(L, "nodeupdate");
|
||||
push_v3s16(L, p);
|
||||
if (lua_pcall(L, 1, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 1, 0, m_errorhandler));
|
||||
}
|
||||
|
||||
void ScriptApiNode::node_falling_update_single(v3s16 p)
|
||||
|
@ -249,7 +241,5 @@ void ScriptApiNode::node_falling_update_single(v3s16 p)
|
|||
|
||||
lua_getglobal(L, "nodeupdate_single");
|
||||
push_v3s16(L, p);
|
||||
if (lua_pcall(L, 1, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 1, 0, m_errorhandler));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue