From 023902341fb23157ecc2c370cc2b6ebb76f95814 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 4 Feb 2015 21:45:27 +0100 Subject: [PATCH] Fix division by zero in hud.value_to_barlength --- init.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 98aabfe..9471c2e 100644 --- a/init.lua +++ b/init.lua @@ -54,7 +54,11 @@ end HUD_TICK = 0.1 function hud.value_to_barlength(value, max) - return math.ceil((value/max) * HUD_BARLENGTH) + if max == 0 then + return 0 + else + return math.ceil((value/max) * HUD_BARLENGTH) + end end function hud.register_hudbar(identifier, text_color, label, textures, default_start_value, default_start_max, start_hide, format_string)