From aa13baa30a45b0f834c23bd5c0407895eb8ec0ee Mon Sep 17 00:00:00 2001 From: TeTpaAka Date: Sat, 30 May 2015 16:56:42 +0200 Subject: Add minetest.register_on_player_hpchange --- src/content_sao.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/content_sao.cpp') diff --git a/src/content_sao.cpp b/src/content_sao.cpp index 1a0fce0bb..318dd367a 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -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) -- cgit v1.2.3