diff options
author | Wuzzy <almikes@aol.com> | 2015-02-12 03:18:58 +0100 |
---|---|---|
committer | Wuzzy <almikes@aol.com> | 2015-02-12 03:18:58 +0100 |
commit | 1d4af7e0eeb5d318f44b2414edbd2f87e582ce05 (patch) | |
tree | a880e658515d920aeb7400edd5e073ca27c44888 | |
parent | 8c17e9373b1afdef547f6153b2396f8b1bed77d3 (diff) |
Harden code against missing icon
-rw-r--r-- | init.lua | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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 |