mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-12 16:58:39 +00:00
Add minetest.register_on_player_hpchange
This commit is contained in:
parent
e50aa4ed06
commit
aa13baa30a
5 changed files with 61 additions and 0 deletions
|
@ -1125,6 +1125,12 @@ void PlayerSAO::setHP(s16 hp)
|
|||
{
|
||||
s16 oldhp = m_player->hp;
|
||||
|
||||
s16 hp_change = m_env->getScriptIface()->on_player_hpchange(this,
|
||||
hp - oldhp);
|
||||
if (hp_change == 0)
|
||||
return;
|
||||
hp = oldhp + hp_change;
|
||||
|
||||
if (hp < 0)
|
||||
hp = 0;
|
||||
else if (hp > PLAYER_MAX_HP)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue