1
0
Fork 0

Cleanup HUD bar mechanics

This commit is contained in:
Brandon 2020-07-27 19:41:07 -04:00
parent 9a32bdc967
commit fd6028e451
1 changed files with 23 additions and 21 deletions

View File

@ -10,6 +10,22 @@ local is_cat = {}
local is_fire_proof = {}
local function potions_set_hudbar(player)
if is_poisoned[player] and is_regenerating[player] then
hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_regen_poison.png", nil, "hudbars_bar_health.png")
elseif is_poisoned[player] then
hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hudbars_bar_health.png")
elseif is_regenerating[player] then
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_regenerate.png", nil, "hudbars_bar_health.png")
else
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png")
end
end
local is_player, entity
minetest.register_globalstep(function(dtime)
@ -55,10 +71,8 @@ minetest.register_globalstep(function(dtime)
if is_poisoned[player].timer >= is_poisoned[player].dur then
is_poisoned[player] = nil
if is_regenerating[player] then
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_regenerate.png", nil, "hudbars_bar_health.png")
else
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png")
if is_player then
potions_set_hudbar(player)
end
end
@ -92,11 +106,7 @@ minetest.register_globalstep(function(dtime)
if is_regenerating[player].timer >= is_regenerating[player].dur then
is_regenerating[player] = nil
if is_player then
if is_poisoned[player] then
hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hudbars_bar_health.png")
else
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png")
end
potions_set_hudbar(player)
end
end
@ -297,7 +307,7 @@ function mcl_potions._reset_player_effects(player)
is_poisoned[player] = nil
if player:is_player() then
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png")
potions_set_hudbar(player)
end
end
@ -307,7 +317,7 @@ function mcl_potions._reset_player_effects(player)
is_regenerating[player] = nil
if player:is_player() then
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png")
potions_set_hudbar(player)
end
end
@ -572,11 +582,7 @@ function mcl_potions.poison_func(player, factor, duration)
is_poisoned[player] = {step = factor, dur = duration, timer = 0}
if player:is_player() then
if is_regenerating[player] then
hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_regen_poison.png", nil, "hudbars_bar_health.png")
else
hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hbhunger_bar_health_poison.png")
end
potions_set_hudbar(player)
end
else
@ -598,11 +604,7 @@ function mcl_potions.regeneration_func(player, factor, duration)
is_regenerating[player] = {step = factor, dur = duration, timer = 0}
if player:is_player() then
if is_poisoned[player] then
hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_regen_poison.png", nil, "hudbars_bar_health.png")
else
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_regenerate.png", nil, "hudbars_bar_health.png")
end
potions_set_hudbar(player)
end
else