forked from mtcontrib/diet
Add support for Better HUD
This commit is contained in:
parent
105cfefa71
commit
1d99cc77b1
1
depends.txt
Normal file
1
depends.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
hud?
|
8
init.lua
8
init.lua
@ -77,6 +77,13 @@ function diet.item_eat(max)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Increase health
|
-- Increase health
|
||||||
|
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
|
||||||
local hp = user:get_hp()
|
local hp = user:get_hp()
|
||||||
if (hp+points > 20) then
|
if (hp+points > 20) then
|
||||||
hp = 20
|
hp = 20
|
||||||
@ -84,6 +91,7 @@ function diet.item_eat(max)
|
|||||||
hp = hp + points
|
hp = hp + points
|
||||||
end
|
end
|
||||||
user:set_hp(hp)
|
user:set_hp(hp)
|
||||||
|
end
|
||||||
|
|
||||||
-- Register
|
-- Register
|
||||||
diet.__register_eat(player,item,ftype)
|
diet.__register_eat(player,item,ftype)
|
||||||
|
Loading…
Reference in New Issue
Block a user