mirror of
git://repo.or.cz/minetest_hbhunger.git
synced 2024-12-23 00:20:16 +01:00
Change health bar color+icon on poisoning
This commit is contained in:
parent
0d1f2fc7cc
commit
30b0b41e3e
10
hunger.lua
10
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
|
||||
|
||||
|
4
init.lua
4
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)
|
||||
|
BIN
textures/hbhunger_bar_health_poison.png
Normal file
BIN
textures/hbhunger_bar_health_poison.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 151 B |
BIN
textures/hbhunger_icon_health_poison.png
Normal file
BIN
textures/hbhunger_icon_health_poison.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 526 B |
Loading…
Reference in New Issue
Block a user