1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-16 18:01:40 +00:00

Give more infos to on_timer() callback

closes #15817
This commit is contained in:
sfan5 2025-08-10 17:22:06 +02:00
parent 7c88996210
commit fd3588d49c
8 changed files with 31 additions and 21 deletions

View file

@ -215,7 +215,7 @@ void ScriptApiNode::node_after_destruct(v3s16 p, MapNode node)
lua_pop(L, 1); // Pop error handler
}
bool ScriptApiNode::node_on_timer(v3s16 p, MapNode node, f32 dtime)
bool ScriptApiNode::node_on_timer(v3s16 p, MapNode node, f32 elapsed, f32 timeout)
{
SCRIPTAPI_PRECHECKHEADER
@ -229,10 +229,14 @@ bool ScriptApiNode::node_on_timer(v3s16 p, MapNode node, f32 dtime)
// Call function
push_v3s16(L, p);
lua_pushnumber(L,dtime);
PCALL_RES(lua_pcall(L, 2, 1, error_handler));
lua_remove(L, error_handler);
return readParam<bool>(L, -1, false);
lua_pushnumber(L, elapsed);
pushnode(L, node);
lua_pushnumber(L, timeout);
PCALL_RES(lua_pcall(L, 4, 1, error_handler));
bool ret = readParam<bool>(L, -1, false);
lua_pop(L, 2); // error handler, return value
return ret;
}
void ScriptApiNode::node_on_receive_fields(v3s16 p,