From 37044bc623063f278ab5c2efe868cc9642b96a36 Mon Sep 17 00:00:00 2001 From: Octav Sandulescu Date: Wed, 7 Oct 2015 09:41:41 +0000 Subject: [PATCH] Format kill count numbers nicely (1,234, not 1234) --- evoGUI.lua | 6 ++++++ value_sensors/kill_count.lua | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/evoGUI.lua b/evoGUI.lua index 72b9c6b..3ed5aec 100644 --- a/evoGUI.lua +++ b/evoGUI.lua @@ -14,6 +14,12 @@ if not evogui.on_click then evogui.on_click = {} end local EXPECTED_VERSION = "{{VERSION}}" +function evogui.format_number(n) -- credit http://richard.warburton.it + local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$') + return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right +end + + function evogui.update_gui() if not global.settings then global.settings = {} end if not global.settings.update_delay then global.settings.update_delay = 60 end diff --git a/value_sensors/kill_count.lua b/value_sensors/kill_count.lua index 5bf2715..f59515d 100644 --- a/value_sensors/kill_count.lua +++ b/value_sensors/kill_count.lua @@ -67,17 +67,17 @@ function sensor:update_ui(owner) local biter_kills = {"sensor.kill_count.biter_fragment_single"} if biter_count ~= 1 then - biter_kills = {"sensor.kill_count.biter_fragment_multiple", biter_count} + biter_kills = {"sensor.kill_count.biter_fragment_multiple", evogui.format_number(biter_count)} end local spawner_kills = {"sensor.kill_count.spawner_fragment_single"} if spawner_count ~= 1 then - spawner_kills = {"sensor.kill_count.spawner_fragment_multiple", spawner_count} + spawner_kills = {"sensor.kill_count.spawner_fragment_multiple", evogui.format_number(spawner_count)} end local other_kills = {"sensor.kill_count.other_fragment_single"} if other_count ~= 1 then - other_kills = {"sensor.kill_count.other_fragment_multiple", other_count} + other_kills = {"sensor.kill_count.other_fragment_multiple", evogui.format_number(other_count)} end owner[self.name].caption = {self.format_key, biter_kills, spawner_kills, other_kills}