summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2015-02-12 05:04:02 +0100
committerWuzzy <almikes@aol.com>2015-02-12 05:04:02 +0100
commitb0eabd3c7a1cb49d7393e60d91c9e9e61602f636 (patch)
tree688abe463e8669fa5a42adc1b90291d785d0e434 /init.lua
parent357229450c8c3b8ba7670025628d78d9a0813818 (diff)
Add basic error reporting for bad value/max combinations
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/init.lua b/init.lua
index a05a31c..51e1901 100644
--- a/init.lua
+++ b/init.lua
@@ -112,6 +112,17 @@ function hb.register_hudbar(identifier, text_color, label, textures, default_sta
state.text = text
state.barlength = hb.value_to_barlength(start_value, start_max)
+
+ if start_max < start_value then
+ minetest.log("error", "[hudbars] Bad initial values of HUD bar identifier “"..tostring(identifier).."” for player "..name..": start_max ("..start_max..") is smaller than start_value ("..start_value..")!")
+ end
+ if start_max < 0 then
+ minetest.log("error", "[hudbars] Bad initial values of HUD bar identifier “"..tostring(identifier).."” for player "..name..": start_max ("..start_max..") is smaller than 0!")
+ end
+ if start_value < 0 then
+ minetest.log("error", "[hudbars] Bad initial values of HUD bar identifier “"..tostring(identifier).."” for player "..name..": start_value ("..start_value..") is smaller than 0!")
+ end
+
hb.hudtables[identifier].hudids[name] = ids
hb.hudtables[identifier].hudstate[name] = state
end
@@ -157,6 +168,16 @@ function hb.change_hudbar(player, identifier, new_value, new_max_value)
new_max_value = hudtable.hudstate[name].max
end
+ if new_max_value < new_value then
+ minetest.log("error", "[hudbars] Bad call to hb.change_hudbar, identifier: “"..tostring(identifier).."”, player name: “"..name.."”. new_max_value ("..new_max_value..") is smaller than new_value ("..new_value..")!")
+ end
+ if new_max_value < 0 then
+ minetest.log("error", "[hudbars] Bad call to hb.change_hudbar, identifier: “"..tostring(identifier).."”, player name: “"..name.."”. new_max_value ("..new_max_value..") is smaller than 0!")
+ end
+ if new_value < 0 then
+ minetest.log("error", "[hudbars] Bad call to hb.change_hudbar, identifier: “"..tostring(identifier).."”, player name: “"..name.."”. new_value ("..new_value..") is smaller than 0!")
+ end
+
if hudtable.hudstate[name].hidden == false then
if max_changed then
if hudtable.hudstate[name].max == 0 then