Production GUI 1dp (#333)

* Update production.lua

* Update production.lua

* Removed repetitive call to string format

---------

Co-authored-by: Cooldude2606 <25043174+Cooldude2606@users.noreply.github.com>
This commit is contained in:
2024-10-20 23:57:12 +09:00
committed by GitHub
parent 2f13aa7e11
commit 16813dca40

View File

@@ -23,7 +23,7 @@ local font_color = {
} }
local function format_n(n) local function format_n(n)
local _i, _j, m, i, f = tostring(n):find('([-]?)(%d+)([.]?%d*)') local _i, _j, m, i, f = string.format('%.1f', n):find('([-]?)(%d+)([.]?%d*)')
i = i:reverse():gsub('(%d%d%d)', '%1,') i = i:reverse():gsub('(%d%d%d)', '%1,')
if f ~= '' then if f ~= '' then
@@ -139,8 +139,8 @@ Event.on_nth_tick(60, function()
local item = table[production_prefix .. '_e'].elem_value local item = table[production_prefix .. '_e'].elem_value
if item then if item then
local add = math.floor(stat.get_flow_count{name=item, input=true, precision_index=precision_value, count=false} / 6) / 10 local add = stat.get_flow_count{name=item, input=true, precision_index=precision_value, count=false} / 60
local minus = math.floor(stat.get_flow_count{name=item, input=false, precision_index=precision_value, count=false} / 6) / 10 local minus = stat.get_flow_count{name=item, input=false, precision_index=precision_value, count=false} / 60
local sum = add - minus local sum = add - minus
table[production_prefix .. '_1'].caption = format_n(add) table[production_prefix .. '_1'].caption = format_n(add)