aloe heals, lack of hunger does not

master
Izzy 2018-03-15 22:47:40 -06:00
parent 5a12c3c518
commit 1e67596643
2 changed files with 12 additions and 5 deletions

View File

@ -25,7 +25,14 @@ minetest.register_craftitem("herbs:aloe_vera", {
inventory_image = "herbs_aloe_vera_plant.png",
groups = {},
on_use = function(itemstack, user, pointed_thing)
local hp = user:get_hp()
if hp < 20 then
hp = hp + 1
if hp > 20 then
hp = 20
end
user:set_hp(hp)
end
end,
})

View File

@ -143,13 +143,13 @@ local function hunger_globaltimer(dtime)
local name = player:get_player_name()
local tab = hunger[name]
if tab then
local air = player:get_breath() or 0
-- local air = player:get_breath() or 0
local hp = player:get_hp()
-- heal player by 1 hp if not dead and saturation is > 15 (of 30) player is not drowning
if tonumber(tab.lvl) > HUNGER_HEAL_LVL and hp > 0 and air > 0 then
player:set_hp(hp + HUNGER_HEAL)
end
-- if tonumber(tab.lvl) > HUNGER_HEAL_LVL and hp > 0 and air > 0 then
-- player:set_hp(hp + HUNGER_HEAL)
-- end
-- or damage player by 1 hp if saturation is < 2 (of 30)
if tonumber(tab.lvl) < HUNGER_STARVE_LVL then