Change health bar color+icon on poisoning

This commit is contained in:
Wuzzy 2016-08-05 15:29:13 +02:00
parent 0d1f2fc7cc
commit 30b0b41e3e
4 changed files with 12 additions and 2 deletions

View File

@ -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

View File

@ -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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B