summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2015-02-12 03:18:58 +0100
committerWuzzy <almikes@aol.com>2015-02-12 03:18:58 +0100
commit1d4af7e0eeb5d318f44b2414edbd2f87e582ce05 (patch)
treea880e658515d920aeb7400edd5e073ca27c44888
parent8c17e9373b1afdef547f6153b2396f8b1bed77d3 (diff)
Harden code against missing icon
-rw-r--r--init.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/init.lua b/init.lua
index 7a84d46..d132bbd 100644
--- a/init.lua
+++ b/init.lua
@@ -185,7 +185,9 @@ function hb.hide_hudbar(player, identifier)
local name = player:get_player_name()
local hudtable = hb.get_hudtable(identifier)
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].bar, "number", 0)
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 value = hudtable.hudstate[name].value
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
player:hud_change(hudtable.hudids[name].bg, "scale", {x=1,y=1})
end