From 9a32bdc967290e74326015685dbf016257c2c9cc Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 27 Jul 2020 19:17:04 -0400 Subject: [PATCH] Update HUD for poison/regen. --- mods/ITEMS/mcl_potions/functions.lua | 32 ++++++++++++++++-- .../textures/hbhunger_icon_regen_poison.png | Bin 0 -> 290 bytes .../textures/hudbars_icon_regenerate.png | Bin 0 -> 305 bytes 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 mods/ITEMS/mcl_potions/textures/hbhunger_icon_regen_poison.png create mode 100644 mods/ITEMS/mcl_potions/textures/hudbars_icon_regenerate.png diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index afe87c367..0c199697a 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -55,7 +55,9 @@ minetest.register_globalstep(function(dtime) if is_poisoned[player].timer >= is_poisoned[player].dur then is_poisoned[player] = nil - if is_player then + 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") end end @@ -89,6 +91,13 @@ 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 + end end end @@ -284,6 +293,7 @@ function mcl_potions._reset_player_effects(player) end if is_poisoned[player] then + is_poisoned[player] = nil if player:is_player() then @@ -293,7 +303,13 @@ function mcl_potions._reset_player_effects(player) end if is_regenerating[player] then + 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") + end + end if is_strong[player] then @@ -556,7 +572,11 @@ function mcl_potions.poison_func(player, factor, duration) is_poisoned[player] = {step = factor, dur = duration, timer = 0} if player:is_player() then - hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hbhunger_bar_health_poison.png") + 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 end else @@ -577,6 +597,14 @@ 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 + end + else local victim = is_regenerating[player] diff --git a/mods/ITEMS/mcl_potions/textures/hbhunger_icon_regen_poison.png b/mods/ITEMS/mcl_potions/textures/hbhunger_icon_regen_poison.png new file mode 100644 index 0000000000000000000000000000000000000000..d4fe9b4e0783d7ddabcc749e79095e880c49af0d GIT binary patch literal 290 zcmeAS@N?(olHy`uVBq!ia0vp^oFL4>1|%O$WD@{VjKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGp-1(_iP|F!_&nvL_#t-L4nDj>B=Ab z|NrbG-qx|P9aC~V_WxsmUBHCGg$l~t9*#e>_%}!ieB94}qMrAm{m!rR9@;x!uNRxK zWeB+sLQ1=cZow;M#cygxLU zHu_lZGHY#|xUffX4TlPMk%5n51mk(n4d)$-3S1LfGve4g8yOhhy|YV>ydJU;1|%O$WD@{VjKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGp-1(_iP}w+|$J|L_#t-L4nDj>B=Ab z|NrbG-qx|P9aC~V_WxsmUBHCGg$l~t9tThHuy2qO__&|{L_Fui`L+KiKD2kfUavMI z=f^*09wVhiJO-=^g^Fci8%$y@Uc3-6qsrp%yXW}^vs)Qo^!>iS&(L5`CGT_=!vjeH zf*pq&-@TZT&n6c1