diff --git a/en/backporting/minetest-engine-api.md b/en/backporting/minetest-engine-api.md new file mode 100644 index 0000000..b53066c --- /dev/null +++ b/en/backporting/minetest-engine-api.md @@ -0,0 +1,33 @@ + + +### reason or PlayerHPChangeReason + +PlayerHPChangeReason table kind of, the minetest api is so crap that does not specified that has properties.. neither refers to the `PlayerHPChangeReason` object, the most important things here are: + +> **since** 5.0 + +* `from` with values of + * `mod` + * `engine` +* `type` values when specific hp actions, and also any of those will have additional fields from mods. + * `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`: the player dies from a high fall or something forced + * `node_damage`: `damage_per_second` from a neighboring node. for older 5.2 use the position of player to get `node_pos` + * `drown`: **since 5.5** + * `respawn`: +* `node` **since 5.3** will hold the node name or nil if `type` is `node_damage`. +* `node_pos` **since 5.3** will hold the position of the node if `type` is `node_damage`. + +### register_on_dieplayer and register_on_player_hpchange + +Those functions for player dead were enhanced since version 5, using new [reason or PlayerHPChangeReason](#reason-or-playerhpchangereason) + +* `minetest.register_on_dieplayer(function(ObjectRef))` **since 0.4.15, 4.0** +* `minetest.register_on_dieplayer(function(ObjectRef, reason))` **since 5.0** + +Those functions ofr player hp change where enhanced since version 5 + +* `minetest.register_on_player_hpchange(func(player, hp_change), modifier)` **since 0.4.15, 4.0** +* `minetest.register_on_player_hpchange(function(player, hp_change, reason), modifier)` **since 5.0** +