Define a reason for set_hp().
I think its useful for hunger_ng
(And other hunger mods) to define the reason for damage so that other mods can use this information to provide better behaviors. For example it will make it possible for 3d_armor to not incur armor damage when eating some foods (e.g. onions) or starving.
However if set_hp()
is called with a custom type
it will print an engine error. See:
https://github.com/minetest/minetest/blob/5146086a64d5eeb480948d612a008a2ec81455d4/src/server/player_sao.h#L252 https://github.com/minetest/minetest/blob/87829cd7446dd13d1dfd27d96e0b4aeb2f234e33/src/script/lua_api/l_object.cpp#L241
From discussing this on #minetest @ freenode I learned this can be worked around by defining a custom variable instead. In this case I think using reason.hunger
instead of reason.type
is good enough.