From 152d69f91f1178b1cd68c3b703734ea3429bfd68 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 13 Aug 2020 18:44:33 +0200 Subject: [PATCH] mcl_hunger: Remove non-food poison mechanic It was moved to mcl_potions, so it's OK --- mods/PLAYER/mcl_hunger/API.md | 2 +- mods/PLAYER/mcl_hunger/api.lua | 2 -- mods/PLAYER/mcl_hunger/hunger.lua | 21 ++++----------------- mods/PLAYER/mcl_hunger/init.lua | 2 -- 4 files changed, 5 insertions(+), 22 deletions(-) diff --git a/mods/PLAYER/mcl_hunger/API.md b/mods/PLAYER/mcl_hunger/API.md index 3daa6351..57d158c4 100644 --- a/mods/PLAYER/mcl_hunger/API.md +++ b/mods/PLAYER/mcl_hunger/API.md @@ -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`. diff --git a/mods/PLAYER/mcl_hunger/api.lua b/mods/PLAYER/mcl_hunger/api.lua index 46dc76fa..55153b9b 100644 --- a/mods/PLAYER/mcl_hunger/api.lua +++ b/mods/PLAYER/mcl_hunger/api.lua @@ -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 diff --git a/mods/PLAYER/mcl_hunger/hunger.lua b/mods/PLAYER/mcl_hunger/hunger.lua index a13e2ae4..42fa219f 100644 --- a/mods/PLAYER/mcl_hunger/hunger.lua +++ b/mods/PLAYER/mcl_hunger/hunger.lua @@ -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 diff --git a/mods/PLAYER/mcl_hunger/init.lua b/mods/PLAYER/mcl_hunger/init.lua index a90bdb73..01d74a80 100644 --- a/mods/PLAYER/mcl_hunger/init.lua +++ b/mods/PLAYER/mcl_hunger/init.lua @@ -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)