mcl_hunger: Remove non-food poison mechanic

It was moved to mcl_potions, so it's OK
This commit is contained in:
Wuzzy 2020-08-13 18:44:33 +02:00
parent cef20edd53
commit 152d69f91f
4 changed files with 5 additions and 22 deletions

View File

@ -41,7 +41,7 @@ Sets the hunger level of `player` (ObjectRef) to `hunger` immediately.
Increase exhaustion of player by `exhaust`.
### `mcl_hunger.stop_poison(player)`
Immediately stops all poisonings for player.
Immediately stops food poisoning for player.
### More functions ...
There are more functions (of less importance) available, see `api.lua`.

View File

@ -113,9 +113,7 @@ if mcl_hunger.active then
if not mcl_hunger.active then
return
end
mcl_hunger.poison_damage[player:get_player_name()] = 0
mcl_hunger.poison_hunger[player:get_player_name()] = 0
mcl_hunger.reset_bars_poison_damage(player)
mcl_hunger.reset_bars_poison_hunger(player)
end

View File

@ -67,10 +67,7 @@ function mcl_hunger.eat(hp_change, replace_with_item, itemstack, user, pointed_t
return func(itemstack, user, pointed_thing)
end
-- Reset HUD bars after poisoning
function mcl_hunger.reset_bars_poison_damage(player)
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png")
end
-- Reset HUD bars after food poisoning
function mcl_hunger.reset_bars_poison_hunger(player)
hb.change_hudbar(player, "hunger", nil, nil, "hbhunger_icon.png", nil, "hbhunger_bar.png")
@ -90,23 +87,17 @@ local function poisonp(tick, time, time_left, damage, exhaustion, name)
return
end
local name = player:get_player_name()
-- Abort if poisonings have been stopped
if mcl_hunger.poison_damage[name] == 0 and mcl_hunger.poison_hunger[name] == 0 then
-- Abort if food poisonings have been stopped
if mcl_hunger.poison_hunger[name] == 0 then
return
end
time_left = time_left + tick
if time_left < time then
minetest.after(tick, poisonp, tick, time, time_left, damage, exhaustion, name)
else
-- if damage > 0 then
-- mcl_hunger.poison_damage[name] = mcl_hunger.poison_damage[name] - 1
-- end
if exhaustion > 0 then
mcl_hunger.poison_hunger [name] = mcl_hunger.poison_hunger[name] - 1
end
-- if mcl_hunger.poison_damage[name] <= 0 then
-- mcl_hunger.reset_bars_poison_damage(player)
-- end
if mcl_hunger.poison_hunger[name] <= 0 then
mcl_hunger.reset_bars_poison_hunger(player)
end
@ -224,11 +215,7 @@ function mcl_hunger.item_eat(hunger_change, replace_with_item, poisontime, poiso
do_poison = true
end
if do_poison then
-- Set poison bars
-- if poison and poison > 0 then
-- hb.change_hudbar(user, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hbhunger_bar_health_poison.png")
-- mcl_hunger.poison_damage[name] = mcl_hunger.poison_damage[name] + 1
-- end
-- Set food poison bars
if exhaust and exhaust > 0 then
hb.change_hudbar(user, "hunger", nil, nil, "mcl_hunger_icon_foodpoison.png", nil, "mcl_hunger_bar_foodpoison.png")
if mcl_hunger.debug then

View File

@ -63,7 +63,6 @@ end
]]
-- Count number of poisonings a player has at once
mcl_hunger.poison_damage = {} -- damaging poison
mcl_hunger.poison_hunger = {} -- food poisoning, increasing hunger
-- HUD item ids
@ -100,7 +99,6 @@ minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
mcl_hunger.init_player(player)
init_hud(player)
mcl_hunger.poison_damage[name] = 0
mcl_hunger.poison_hunger[name] = 0
mcl_hunger.last_eat[name] = -1
end)