diff --git a/exp_legacy/module/modules/gui/production.lua b/exp_legacy/module/modules/gui/production.lua index 20c6e51d..85f239de 100644 --- a/exp_legacy/module/modules/gui/production.lua +++ b/exp_legacy/module/modules/gui/production.lua @@ -24,7 +24,6 @@ local function format_n(amount) if math.abs(amount) < 0.009 then return "0.00" end - local suffix = "" local suffix_list = { ["T"] = 1e12, @@ -32,7 +31,6 @@ local function format_n(amount) ["M"] = 1e6, ["k"] = 1e3 } - local scale = 1 for letter, limit in pairs(suffix_list) do if math.abs(amount) >= limit then @@ -41,19 +39,15 @@ local function format_n(amount) break end end - local scaled_value = amount / scale local formatted = string.format("%.2f", scaled_value) - -- Split into integer and fractional parts local integer_part, fractional_part = formatted:match("^(%-?%d+)%.(%d+)$") integer_part = integer_part or formatted fractional_part = fractional_part or "00" - -- Add commas to integer part integer_part = integer_part:reverse():gsub("(%d%d%d)", "%1,"):reverse() integer_part = integer_part:gsub("^,", ""):gsub("-,", "-") - -- Handle numbers below 1000 without suffix if scale == 1 then -- Remove trailing .00 for whole numbers @@ -62,13 +56,9 @@ local function format_n(amount) end return string.format("%s.%s", integer_part, fractional_part) end - -- Combine parts and add suffix - return string.format("%s.%s %s", - integer_part, - fractional_part, - suffix - ):gsub("%.?0+ %k$", " "..suffix) -- Clean up trailing zeros + -- Clean up trailing zeros + return string.format("%s.%s %s", integer_part, fractional_part, suffix):gsub("%.?0+ %k$", " " .. suffix) end --- Display group