mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-01 17:38:41 +00:00
Allow nil
puncher in object:punch
(#14319)
This commit is contained in:
parent
fc0ac64277
commit
72cb4e9bea
11 changed files with 89 additions and 36 deletions
|
@ -262,8 +262,6 @@ bool ScriptApiEntity::luaentity_Punch(u16 id,
|
|||
{
|
||||
SCRIPTAPI_PRECHECKHEADER
|
||||
|
||||
assert(puncher);
|
||||
|
||||
int error_handler = PUSH_ERROR_HANDLER(L);
|
||||
|
||||
// Get core.luaentities[id]
|
||||
|
@ -278,7 +276,10 @@ bool ScriptApiEntity::luaentity_Punch(u16 id,
|
|||
}
|
||||
luaL_checktype(L, -1, LUA_TFUNCTION);
|
||||
lua_pushvalue(L, object); // self
|
||||
objectrefGetOrCreate(L, puncher); // Clicker reference
|
||||
if (puncher)
|
||||
objectrefGetOrCreate(L, puncher); // Puncher reference
|
||||
else
|
||||
lua_pushnil(L);
|
||||
lua_pushnumber(L, time_from_last_punch);
|
||||
push_tool_capabilities(L, *toolcap);
|
||||
push_v3f(L, dir);
|
||||
|
|
|
@ -68,7 +68,10 @@ bool ScriptApiPlayer::on_punchplayer(ServerActiveObject *player,
|
|||
lua_getfield(L, -1, "registered_on_punchplayers");
|
||||
// Call callbacks
|
||||
objectrefGetOrCreate(L, player);
|
||||
objectrefGetOrCreate(L, hitter);
|
||||
if (hitter)
|
||||
objectrefGetOrCreate(L, hitter);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
lua_pushnumber(L, time_from_last_punch);
|
||||
push_tool_capabilities(L, *toolcap);
|
||||
push_v3f(L, dir);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue