diff options
author | TeTpaAka <TeTpaAka@users.noreply.github.com> | 2015-05-30 16:56:42 +0200 |
---|---|---|
committer | est31 <MTest31@outlook.com> | 2015-06-13 19:40:31 +0200 |
commit | aa13baa30a45b0f834c23bd5c0407895eb8ec0ee (patch) | |
tree | 23fc218db4ad9fe4cb44f83fbaf40ac181335c8d /src/content_sao.cpp | |
parent | e50aa4ed06f36c74a892ec68d576c52ba9dc0b2c (diff) | |
download | minetest-aa13baa30a45b0f834c23bd5c0407895eb8ec0ee.tar.gz minetest-aa13baa30a45b0f834c23bd5c0407895eb8ec0ee.tar.bz2 minetest-aa13baa30a45b0f834c23bd5c0407895eb8ec0ee.zip |
Add minetest.register_on_player_hpchange
Diffstat (limited to 'src/content_sao.cpp')
-rw-r--r-- | src/content_sao.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
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) |