forked from mtcontrib/minetest_hudbars
Add forgotten 0/0 corner cases
This commit is contained in:
parent
e6e8f2d688
commit
6e1b5be68d
10
init.lua
10
init.lua
@ -83,10 +83,16 @@ function hud.register_hudbar(identifier, text_color, label, textures, default_st
|
|||||||
local ids = {}
|
local ids = {}
|
||||||
local state = {}
|
local state = {}
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
local bgscale
|
||||||
|
if start_max == 0 then
|
||||||
|
bgscale = { x=0, y=0 }
|
||||||
|
else
|
||||||
|
bgscale = { x=1, y=1 }
|
||||||
|
end
|
||||||
ids.bg = player:hud_add({
|
ids.bg = player:hud_add({
|
||||||
hud_elem_type = "image",
|
hud_elem_type = "image",
|
||||||
position = pos,
|
position = pos,
|
||||||
scale = { x = 1, y = 1 },
|
scale = bgscale,
|
||||||
text = "hudbars_bar_background.png",
|
text = "hudbars_bar_background.png",
|
||||||
alignment = {x=1,y=1},
|
alignment = {x=1,y=1},
|
||||||
offset = { x = offset.x - 1, y = offset.y - 1 },
|
offset = { x = offset.x - 1, y = offset.y - 1 },
|
||||||
@ -172,7 +178,7 @@ function hud.unhide_hudbar(player, hudtable)
|
|||||||
local value = hudtable.hudstate[name].value
|
local value = hudtable.hudstate[name].value
|
||||||
local max = hudtable.hudstate[name].max
|
local max = hudtable.hudstate[name].max
|
||||||
player:hud_change(hudtable.hudids[name].icon, "scale", {x=1,y=1})
|
player:hud_change(hudtable.hudids[name].icon, "scale", {x=1,y=1})
|
||||||
if hudtable.hudstate[name].max == 0 then
|
if hudtable.hudstate[name].max ~= 0 then
|
||||||
player:hud_change(hudtable.hudids[name].bg, "scale", {x=1,y=1})
|
player:hud_change(hudtable.hudids[name].bg, "scale", {x=1,y=1})
|
||||||
end
|
end
|
||||||
player:hud_change(hudtable.hudids[name].bar, "number", hud.value_to_barlength(value, max))
|
player:hud_change(hudtable.hudids[name].bar, "number", hud.value_to_barlength(value, max))
|
||||||
|
Loading…
Reference in New Issue
Block a user