mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-28 13:53:45 +01:00
Add dummy saturation for eating food
This commit is contained in:
parent
7c5b613032
commit
a300831614
@ -139,18 +139,17 @@ function mcl_hunger.item_eat(hunger_change, replace_with_item, poisen, heal, sou
|
||||
})
|
||||
end
|
||||
|
||||
-- Saturation
|
||||
-- Food points
|
||||
if h < 20 and hunger_change then
|
||||
h = h + hunger_change
|
||||
if h > 20 then h = 20 end
|
||||
mcl_hunger.hunger[name] = h
|
||||
mcl_hunger.set_hunger_raw(user)
|
||||
end
|
||||
-- Healing
|
||||
if hp < 20 and heal then
|
||||
hp = hp + heal
|
||||
if hp > 20 then hp = 20 end
|
||||
user:set_hp(hp)
|
||||
-- Dummy saturation (= hunger change)
|
||||
-- TODO: Use food's actual saturation value
|
||||
if hunger_change then
|
||||
mcl_hunger.saturate(name, hunger_change)
|
||||
end
|
||||
-- Poison
|
||||
if poisen then
|
||||
|
@ -150,11 +150,11 @@ end
|
||||
|
||||
function mcl_hunger.saturate(playername, increase)
|
||||
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
|
||||
mcl_hunger.saturation[playername] = mcl_hunger.get_hunger(player)
|
||||
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
|
||||
|
||||
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
|
||||
-- TODO: Add exhaustion for moving in water
|
||||
end
|
||||
if controls.jump then
|
||||
mcl_hunger.exhaust(name, mcl_hunger.EXHAUST_JUMP)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user