From 1f9ec260332140da07d45c3aa6fc83c4f5699e37 Mon Sep 17 00:00:00 2001 From: alek13 Date: Mon, 22 Sep 2025 03:30:28 +0300 Subject: [PATCH] Modern Lua Plugins: fix errors in `mods/lord/Core/damage`. LG-1980 --- classes/ObjectRef.lua | 7 ++++--- core_namespace.lua | 13 ++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/classes/ObjectRef.lua b/classes/ObjectRef.lua index 80e0913..30cddf4 100644 --- a/classes/ObjectRef.lua +++ b/classes/ObjectRef.lua @@ -40,6 +40,7 @@ function ObjectRef:punch(puncher, time_from_last_punch, tool_capabilities, direc --- @param clicker ObjectRef function ObjectRef:right_click(clicker) end --- returns number of health points +--- @return number function ObjectRef:get_hp() end --- set number of health points --- * See reason in register_on_player_hpchange @@ -74,8 +75,8 @@ function ObjectRef:get_animation() end --- @param frame_speed number default: `15.0` function ObjectRef:set_animation_frame_speed(frame_speed) end ---- Attaches object to `parent`. ---- See 'Attachments' section for details. +--- Attaches object to `parent`. +--- See 'Attachments' section for details. --- This command may fail silently (do nothing) when it would result in circular attachments. --- @overload fun(parent:ObjectRef) --- @param parent ObjectRef to attach to @@ -84,7 +85,7 @@ function ObjectRef:set_animation_frame_speed(frame_speed) end --- @param rotation Position|vector relative rotation in degrees, default `{x=0, y=0, z=0}` --- @param forced_visible boolean to control whether the attached entity should appear in first person, default `false`. function ObjectRef:set_attach(parent, bone, position, rotation, forced_visible) end ---- Returns current attachment parameters or nil if it isn't attached. +--- Returns current attachment parameters or nil if it isn't attached. --- If attached, returns `parent`, `bone`, `position`, `rotation`, `forced_visible`. --- @return ObjectRef,string,Position,Position,boolean|nil function ObjectRef:get_attach() end diff --git a/core_namespace.lua b/core_namespace.lua index f3639a1..92aa3b5 100644 --- a/core_namespace.lua +++ b/core_namespace.lua @@ -514,10 +514,21 @@ function minetest.register_on_punchplayer(callback) end --- @param callback fun(player:Player, clicker:Player) function minetest.register_on_rightclickplayer(callback) end +--- @alias PlayerHPChangeReasonType +--- | "set_hp" # A mod or the engine called `set_hp` without giving a type - use this for custom damage types. +--- | "punch" # Was punched. `reason.object` will hold the puncher, or nil if none. +--- | "fall" # A fall. +--- | "node_damage" # `damage_per_second` from a neighbouring node. `reason.node` will hold the node name or nil. +--- | "drown" # Drowning damage. +--- | "respawn" # Respawning. + + --- @class PlayerHPChangeReason ---- @field type string one of `"set_hp"`, `"punch"`, ... See `register_on_player_hpchange` description. +--- @field type PlayerHPChangeReasonType one of `"set_hp"`, `"punch"`, ... See `register_on_player_hpchange` description. --- @field from string will be `"mod"` or `"engine"` --- @field object ObjectRef|Player|Entity +--- @field node string|nil +--- @field node_pos Position|nil --- * Called when the player gets damaged or healed --- * `player`: ObjectRef of the player