From 705d651677fa0fb5dc500c1e558e6a2446e672a0 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 29 Jul 2021 20:07:38 +0300 Subject: [PATCH] Add covid tracking script --- covid-widget.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/covid-widget.lua b/covid-widget.lua index d163af3..472f8e4 100644 --- a/covid-widget.lua +++ b/covid-widget.lua @@ -9,7 +9,13 @@ function onNetworkResult(result) local totalDeaths = json:getValue(result, "object object:Global int:TotalDeaths") ui:showLines({ - "Disease: total = "..total.." new = "..new, - "Deaths: total = "..totalDeaths.." new = "..newDeaths + "Disease: total = "..comma_value(total).." new = "..comma_value(new), + "Deaths: total = "..comma_value(totalDeaths).." new = "..comma_value(newDeaths) }) end + +function comma_value(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 +