mirror of
https://repo.or.cz/minetest_hudbars.git
synced 2024-08-20 05:04:12 +02:00
Harden code against missing icon
This commit is contained in:
parent
8c17e9373b
commit
1d4af7e0ee
8
init.lua
8
init.lua
@ -185,7 +185,9 @@ 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.hudstate[name].hidden == false) then
|
if(hudtable.hudstate[name].hidden == false) then
|
||||||
player:hud_change(hudtable.hudids[name].icon, "scale", {x=0,y=0})
|
if hudtable.hudids[name].icon ~= nil then
|
||||||
|
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].bg, "scale", {x=0,y=0})
|
||||||
player:hud_change(hudtable.hudids[name].bar, "number", 0)
|
player:hud_change(hudtable.hudids[name].bar, "number", 0)
|
||||||
player:hud_change(hudtable.hudids[name].text, "text", "")
|
player:hud_change(hudtable.hudids[name].text, "text", "")
|
||||||
@ -200,7 +202,9 @@ function hb.unhide_hudbar(player, identifier)
|
|||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
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})
|
if hudtable.hudids[name].icon ~= nil then
|
||||||
|
player:hud_change(hudtable.hudids[name].icon, "scale", {x=1,y=1})
|
||||||
|
end
|
||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user