diff options
author | rubenwardy <anjayward@gmail.com> | 2014-04-13 19:48:54 +0100 |
---|---|---|
committer | rubenwardy <anjayward@gmail.com> | 2014-04-13 19:48:54 +0100 |
commit | 1d99cc77b18d33e0ef38f75d208047cdf9fdfccd (patch) | |
tree | 03881db1f37d457c62ee6a9000ea2bf76168575a | |
parent | 105cfefa71b1dfd0aecb52c64dea51fe5bcac84a (diff) |
Add support for Better HUD
-rw-r--r-- | depends.txt | 1 | ||||
-rw-r--r-- | init.lua | 20 |
2 files changed, 15 insertions, 6 deletions
diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..b2e8e25 --- /dev/null +++ b/depends.txt @@ -0,0 +1 @@ +hud? @@ -77,13 +77,21 @@ function diet.item_eat(max) end -- Increase health - local hp = user:get_hp() - if (hp+points > 20) then - hp = 20 + if minetest.get_modpath("hud") and hud then + local h = tonumber(hud.hunger[name]) + h = h + points + if h>30 then h = 30 end + hud.hunger[name] = h + hud.save_hunger(user) else - hp = hp + points - end - user:set_hp(hp) + local hp = user:get_hp() + if (hp+points > 20) then + hp = 20 + else + hp = hp + points + end + user:set_hp(hp) + end -- Register diet.__register_eat(player,item,ftype) |