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:
parent
4374f1d7ed
commit
9fad09d4a1
3 changed files with 8 additions and 7 deletions
|
@ -1346,7 +1346,7 @@ local function handle_kill_command(killer, victim)
|
|||
core.log("action", string.format("%s killed %s", killer, victim))
|
||||
end
|
||||
-- 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)
|
||||
end
|
||||
|
||||
|
|
|
@ -435,7 +435,7 @@ function core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed
|
|||
core.add_item(pos, replace_with_item)
|
||||
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
|
||||
end
|
||||
|
|
|
@ -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.
|
||||
`reason.node` and `reason.node_pos` are same as for `node_damage`
|
||||
* `respawn`: HP restored by respawning.
|
||||
* The `detail` field may optionally be used to provide a more detailed reason
|
||||
as a string. It's recommended to follow the `modname:detail` naming convention.
|
||||
These detail names exist by default:
|
||||
* `__builtin:item_eat`: HP change caused by `core.do_item_eat`
|
||||
* `__builtin:kill_command`: `/kill` command
|
||||
* `item_eat`: HP change caused by `core.do_item_eat`
|
||||
* `kill_command`: `/kill` command
|
||||
* A custom value. This may be used by mods to inform other mods
|
||||
about a damage type when none of the above applies. It should
|
||||
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:
|
||||
* `engine`: Engine
|
||||
* `mod`: Mod or builtin
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue