Add dummy saturation for eating food

This commit is contained in:
Wuzzy 2017-05-20 16:59:11 +02:00
parent 7c5b613032
commit a300831614
2 changed files with 10 additions and 8 deletions

View File

@ -139,18 +139,17 @@ function mcl_hunger.item_eat(hunger_change, replace_with_item, poisen, heal, sou
}) })
end end
-- Saturation -- Food points
if h < 20 and hunger_change then if h < 20 and hunger_change then
h = h + hunger_change h = h + hunger_change
if h > 20 then h = 20 end if h > 20 then h = 20 end
mcl_hunger.hunger[name] = h mcl_hunger.hunger[name] = h
mcl_hunger.set_hunger_raw(user) mcl_hunger.set_hunger_raw(user)
end end
-- Healing -- Dummy saturation (= hunger change)
if hp < 20 and heal then -- TODO: Use food's actual saturation value
hp = hp + heal if hunger_change then
if hp > 20 then hp = 20 end mcl_hunger.saturate(name, hunger_change)
user:set_hp(hp)
end end
-- Poison -- Poison
if poisen then if poisen then

View File

@ -150,11 +150,11 @@ end
function mcl_hunger.saturate(playername, increase) function mcl_hunger.saturate(playername, increase)
local player = minetest.get_player_by_name(playername) local player = minetest.get_player_by_name(playername)
mcl_hunger.exhaustion[playername] = mcl_hunger.exhaustion[playername] + increase mcl_hunger.saturation[playername] = mcl_hunger.saturation[playername] + increase
if mcl_hunger.saturation[playername] > mcl_hunger.get_hunger(player) then if mcl_hunger.saturation[playername] > mcl_hunger.get_hunger(player) then
mcl_hunger.saturation[playername] = mcl_hunger.get_hunger(player) mcl_hunger.saturation[playername] = mcl_hunger.get_hunger(player)
end end
hb.change_hudbar(player, "saturation", mcl_hunger.saturation[playername]) hb.change_hudbar(player, "saturation", mcl_hunger.saturation[playername], mcl_hunger.get_hunger(player))
end end
local main_timer = 0 local main_timer = 0
@ -214,6 +214,9 @@ minetest.register_globalstep(function(dtime)
if controls.up or controls.down or controls.left or controls.right then if controls.up or controls.down or controls.left or controls.right then
-- TODO: Add exhaustion for moving in water -- TODO: Add exhaustion for moving in water
end end
if controls.jump then
mcl_hunger.exhaust(name, mcl_hunger.EXHAUST_JUMP)
end
end end
end end
end end