summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2015-02-09 23:13:33 +0100
committerWuzzy <almikes@aol.com>2015-02-09 23:13:33 +0100
commit79997659d937e83071bb37d3a4d48e52d4155117 (patch)
tree57b3d8389abac34fe20192678caf77762bbfc94e /init.lua
parent28551721f4179ca4ec15930d49c8ddcfa05eff58 (diff)
Allow hud.change_hudbar to change only one or no value of both
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua18
1 files changed, 16 insertions, 2 deletions
diff --git a/init.lua b/init.lua
index c6ac921..32ac1bf 100644
--- a/init.lua
+++ b/init.lua
@@ -156,10 +156,24 @@ function hud.init_hudbar(player, identifier, start_value, start_max)
end
function hud.change_hudbar(player, identifier, new_value, new_max_value)
+ if new_value == nil and new_max_value == nil then
+ return
+ end
+
local name = player:get_player_name()
local hudtable = hud.get_hudtable(identifier)
- hudtable.hudstate[name].value = new_value
- hudtable.hudstate[name].max = new_max_value
+
+ if new_value ~= nil then
+ hudtable.hudstate[name].value = new_value
+ else
+ new_value = hudtable.hudstate[name].value
+ end
+ if new_max_value ~= nil then
+ hudtable.hudstate[name].max = new_max_value
+ else
+ new_max_value = hudtable.hudstate[name].max
+ end
+
if hudtable.hudstate[name].hidden == false then
if hudtable.hudstate[name].max == 0 then
player:hud_change(hudtable.hudids[name].bg, "scale", {x=0,y=0})