forked from mtcontrib/minetest_hudbars
Always send update when changing hide state
This fixes a problem in hbarmor not getting the correct hide state initially.
This commit is contained in:
parent
895fcae716
commit
915fab08e2
48
init.lua
48
init.lua
@ -384,19 +384,17 @@ function hb.hide_hudbar(player, identifier)
|
|||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local hudtable = hb.get_hudtable(identifier)
|
local hudtable = hb.get_hudtable(identifier)
|
||||||
if hudtable == nil then return false end
|
if hudtable == nil then return false end
|
||||||
if(hudtable.hudstate[name].hidden == false) then
|
if hb.settings.bar_type == "progress_bar" then
|
||||||
if hb.settings.bar_type == "progress_bar" then
|
if hudtable.hudids[name].icon ~= nil then
|
||||||
if hudtable.hudids[name].icon ~= nil then
|
player:hud_change(hudtable.hudids[name].icon, "scale", {x=0,y=0})
|
||||||
player:hud_change(hudtable.hudids[name].icon, "scale", {x=0,y=0})
|
|
||||||
end
|
|
||||||
player:hud_change(hudtable.hudids[name].bg, "scale", {x=0,y=0})
|
|
||||||
player:hud_change(hudtable.hudids[name].text, "text", "")
|
|
||||||
elseif hb.settings.bar_type == "statbar_modern" then
|
|
||||||
player:hud_change(hudtable.hudids[name].bg, "number", 0)
|
|
||||||
end
|
end
|
||||||
player:hud_change(hudtable.hudids[name].bar, "number", 0)
|
player:hud_change(hudtable.hudids[name].bg, "scale", {x=0,y=0})
|
||||||
hudtable.hudstate[name].hidden = true
|
player:hud_change(hudtable.hudids[name].text, "text", "")
|
||||||
|
elseif hb.settings.bar_type == "statbar_modern" then
|
||||||
|
player:hud_change(hudtable.hudids[name].bg, "number", 0)
|
||||||
end
|
end
|
||||||
|
player:hud_change(hudtable.hudids[name].bar, "number", 0)
|
||||||
|
hudtable.hudstate[name].hidden = true
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -405,23 +403,21 @@ function hb.unhide_hudbar(player, identifier)
|
|||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local hudtable = hb.get_hudtable(identifier)
|
local hudtable = hb.get_hudtable(identifier)
|
||||||
if hudtable == nil then return false end
|
if hudtable == nil then return false end
|
||||||
if(hudtable.hudstate[name].hidden) then
|
local value = hudtable.hudstate[name].value
|
||||||
local value = hudtable.hudstate[name].value
|
local max = hudtable.hudstate[name].max
|
||||||
local max = hudtable.hudstate[name].max
|
if hb.settings.bar_type == "progress_bar" then
|
||||||
if hb.settings.bar_type == "progress_bar" then
|
if hudtable.hudids[name].icon ~= nil then
|
||||||
if hudtable.hudids[name].icon ~= nil then
|
player:hud_change(hudtable.hudids[name].icon, "scale", {x=1,y=1})
|
||||||
player:hud_change(hudtable.hudids[name].icon, "scale", {x=1,y=1})
|
|
||||||
end
|
|
||||||
if hudtable.hudstate[name].max ~= 0 then
|
|
||||||
player:hud_change(hudtable.hudids[name].bg, "scale", {x=1,y=1})
|
|
||||||
end
|
|
||||||
player:hud_change(hudtable.hudids[name].text, "text", make_label(hudtable.format_string, hudtable.format_string_config, hudtable.format_string_textdomain, hudtable.label, value, max))
|
|
||||||
elseif hb.settings.bar_type == "statbar_modern" then
|
|
||||||
player:hud_change(hudtable.hudids[name].bg, "number", hb.settings.statbar_length)
|
|
||||||
end
|
end
|
||||||
player:hud_change(hudtable.hudids[name].bar, "number", hb.value_to_barlength(value, max))
|
if hudtable.hudstate[name].max ~= 0 then
|
||||||
hudtable.hudstate[name].hidden = false
|
player:hud_change(hudtable.hudids[name].bg, "scale", {x=1,y=1})
|
||||||
|
end
|
||||||
|
player:hud_change(hudtable.hudids[name].text, "text", make_label(hudtable.format_string, hudtable.format_string_config, hudtable.format_string_textdomain, hudtable.label, value, max))
|
||||||
|
elseif hb.settings.bar_type == "statbar_modern" then
|
||||||
|
player:hud_change(hudtable.hudids[name].bg, "number", hb.settings.statbar_length)
|
||||||
end
|
end
|
||||||
|
player:hud_change(hudtable.hudids[name].bar, "number", hb.value_to_barlength(value, max))
|
||||||
|
hudtable.hudstate[name].hidden = false
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user