1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-05 19:31:04 +00:00

PlayerHPChangeReason: Replace detail by 2 types

This commit is contained in:
Wuzzy 2025-07-04 12:48:23 +02:00
parent 4374f1d7ed
commit 9fad09d4a1
3 changed files with 8 additions and 7 deletions

View file

@ -1346,7 +1346,7 @@ local function handle_kill_command(killer, victim)
core.log("action", string.format("%s killed %s", killer, victim)) core.log("action", string.format("%s killed %s", killer, victim))
end end
-- Kill victim -- Kill victim
victimref:set_hp(0, {type="set_hp", detail="__builtin:kill_command"}) victimref:set_hp(0, {type="kill_command"})
return true, S("@1 has been killed.", victim) return true, S("@1 has been killed.", victim)
end end

View file

@ -435,7 +435,7 @@ function core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed
core.add_item(pos, replace_with_item) core.add_item(pos, replace_with_item)
end end
user:set_hp(user:get_hp() + hp_change, {type="set_hp", detail="__builtin:item_eat"}) user:set_hp(user:get_hp() + hp_change, {type="item_eat"})
return nil -- don't overwrite wield item a second time return nil -- don't overwrite wield item a second time
end end

View file

@ -11089,11 +11089,12 @@ The `PlayerHPChangeReason` table specifies a reason for player health changes.
* `drown`: Drowning damage from a node with the `drowning` field set. * `drown`: Drowning damage from a node with the `drowning` field set.
`reason.node` and `reason.node_pos` are same as for `node_damage` `reason.node` and `reason.node_pos` are same as for `node_damage`
* `respawn`: HP restored by respawning. * `respawn`: HP restored by respawning.
* The `detail` field may optionally be used to provide a more detailed reason * `item_eat`: HP change caused by `core.do_item_eat`
as a string. It's recommended to follow the `modname:detail` naming convention. * `kill_command`: `/kill` command
These detail names exist by default: * A custom value. This may be used by mods to inform other mods
* `__builtin:item_eat`: HP change caused by `core.do_item_eat` about a damage type when none of the above applies. It should
* `__builtin:kill_command`: `/kill` command follow a `_<modname>:<detail>` naming convention.
Example: `_example:poison` for poison damage from a mod named `example`
* The `from` field denotes the origin of the HP change: * The `from` field denotes the origin of the HP change:
* `engine`: Engine * `engine`: Engine
* `mod`: Mod or builtin * `mod`: Mod or builtin