summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hunger.lua10
-rw-r--r--init.lua4
-rw-r--r--textures/hbhunger_bar_health_poison.pngbin0 -> 151 bytes
-rw-r--r--textures/hbhunger_icon_health_poison.pngbin0 -> 526 bytes
4 files changed, 12 insertions, 2 deletions
diff --git a/hunger.lua b/hunger.lua
index 1bffccd..b181c2e 100644
--- a/hunger.lua
+++ b/hunger.lua
@@ -54,7 +54,11 @@ local function poisenp(tick, time, time_left, player)
if time_left < time then
minetest.after(tick, poisenp, tick, time, time_left, player)
else
- --reset hud image
+ hbhunger.poisonings[player:get_player_name()] = hbhunger.poisonings[player:get_player_name()] - 1
+ if hbhunger.poisonings[player:get_player_name()] <= 0 then
+ -- Reset HUD bar color
+ hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png")
+ end
end
if player:get_hp()-1 > 0 then
player:set_hp(player:get_hp()-1)
@@ -85,7 +89,9 @@ function hbhunger.item_eat(hunger_change, replace_with_item, poisen, heal)
end
-- Poison
if poisen then
- --set hud-img
+ -- Set poison bar
+ hb.change_hudbar(user, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hbhunger_bar_health_poison.png")
+ hbhunger.poisonings[name] = hbhunger.poisonings[name] + 1
poisenp(1.0, poisen, 0, user)
end
diff --git a/init.lua b/init.lua
index 0fb5f31..46158ac 100644
--- a/init.lua
+++ b/init.lua
@@ -7,6 +7,9 @@ hbhunger.food = {}
hbhunger.hunger = {}
hbhunger.hunger_out = {}
+-- Count number of poisonings a player has at once
+hbhunger.poisonings = {}
+
-- HUD item ids
local hunger_hud = {}
@@ -83,6 +86,7 @@ minetest.register_on_joinplayer(function(player)
hbhunger.hunger[name] = hbhunger.get_hunger(player)
hbhunger.hunger_out[name] = hbhunger.hunger[name]
hbhunger.exhaustion[name] = 0
+ hbhunger.poisonings[name] = 0
custom_hud(player)
hbhunger.set_hunger(player)
end)
diff --git a/textures/hbhunger_bar_health_poison.png b/textures/hbhunger_bar_health_poison.png
new file mode 100644
index 0000000..255a287
--- /dev/null
+++ b/textures/hbhunger_bar_health_poison.png
Binary files differ
diff --git a/textures/hbhunger_icon_health_poison.png b/textures/hbhunger_icon_health_poison.png
new file mode 100644
index 0000000..8ce2db8
--- /dev/null
+++ b/textures/hbhunger_icon_health_poison.png
Binary files differ