forked from mtcontrib/minetest_hudbars
Fix start_hidden parameter
This commit is contained in:
parent
20a13045f7
commit
8c17e9373b
18
init.lua
18
init.lua
|
@ -55,12 +55,21 @@ function hb.register_hudbar(identifier, text_color, label, textures, default_sta
|
||||||
local ids = {}
|
local ids = {}
|
||||||
local state = {}
|
local state = {}
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local bgscale
|
local bgscale, iconscale, text, barnumber
|
||||||
if start_max == 0 then
|
if start_max == 0 or start_hidden then
|
||||||
bgscale = { x=0, y=0 }
|
bgscale = { x=0, y=0 }
|
||||||
else
|
else
|
||||||
bgscale = { x=1, y=1 }
|
bgscale = { x=1, y=1 }
|
||||||
end
|
end
|
||||||
|
if start_hidden then
|
||||||
|
iconscale = { x=0, y=0 }
|
||||||
|
barnumber = 0
|
||||||
|
text = ""
|
||||||
|
else
|
||||||
|
iconscale = { x=1, y=1 }
|
||||||
|
barnumber = hb.value_to_barlength(start_value, start_max)
|
||||||
|
text = string.format(format_string, label, start_value, start_max)
|
||||||
|
end
|
||||||
ids.bg = player:hud_add({
|
ids.bg = player:hud_add({
|
||||||
hud_elem_type = "image",
|
hud_elem_type = "image",
|
||||||
position = pos,
|
position = pos,
|
||||||
|
@ -73,7 +82,7 @@ function hb.register_hudbar(identifier, text_color, label, textures, default_sta
|
||||||
ids.icon = player:hud_add({
|
ids.icon = player:hud_add({
|
||||||
hud_elem_type = "image",
|
hud_elem_type = "image",
|
||||||
position = pos,
|
position = pos,
|
||||||
scale = { x = 1, y = 1 },
|
scale = iconscale,
|
||||||
text = textures.icon,
|
text = textures.icon,
|
||||||
alignment = {x=-1,y=1},
|
alignment = {x=-1,y=1},
|
||||||
offset = { x = offset.x - 3, y = offset.y },
|
offset = { x = offset.x - 3, y = offset.y },
|
||||||
|
@ -83,11 +92,10 @@ function hb.register_hudbar(identifier, text_color, label, textures, default_sta
|
||||||
hud_elem_type = "statbar",
|
hud_elem_type = "statbar",
|
||||||
position = pos,
|
position = pos,
|
||||||
text = textures.bar,
|
text = textures.bar,
|
||||||
number = hb.value_to_barlength(start_value, start_max),
|
number = barnumber,
|
||||||
alignment = {x=-1,y=-1},
|
alignment = {x=-1,y=-1},
|
||||||
offset = offset,
|
offset = offset,
|
||||||
})
|
})
|
||||||
local text = string.format(format_string, label, start_value, start_max)
|
|
||||||
ids.text = player:hud_add({
|
ids.text = player:hud_add({
|
||||||
hud_elem_type = "text",
|
hud_elem_type = "text",
|
||||||
position = pos,
|
position = pos,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user