1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-15 01:25:20 +02:00

Add minetest.register_on_player_hpchange

This commit is contained in:
TeTpaAka
2015-05-30 16:56:42 +02:00
committed by est31
parent e50aa4ed06
commit aa13baa30a
5 changed files with 61 additions and 0 deletions

View File

@@ -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)