someone had PFE in an induction matrix so now i've gotta support some bigger numbers in the power format

This commit is contained in:
Mikayla Fischler 2022-11-10 12:00:23 -05:00
parent 806b217d58
commit bc63a06b09
2 changed files with 21 additions and 9 deletions

View File

@ -16,7 +16,7 @@ local config = require("coordinator.config")
local coordinator = require("coordinator.coordinator")
local renderer = require("coordinator.renderer")
local COORDINATOR_VERSION = "alpha-v0.6.3"
local COORDINATOR_VERSION = "alpha-v0.6.4"
local print = util.print
local println = util.println

View File

@ -364,11 +364,14 @@ local function kFE(fe) return fe / 1000.0 end
local function MFE(fe) return fe / 1000000.0 end
local function GFE(fe) return fe / 1000000000.0 end
local function TFE(fe) return fe / 1000000000000.0 end
local function PFE(fe) return fe / 1000000000000000.0 end
local function EFE(fe) return fe / 1000000000000000000.0 end -- if you accomplish this please touch grass
local function ZFE(fe) return fe / 1000000000000000000000.0 end -- please stop
-- format a power value into XXX.XX UNIT format (FE, kFE, MFE, GFE, TFE)
-- format a power value into XXX.XX UNIT format (FE, kFE, MFE, GFE, TFE, PFE, EFE, ZFE)
---@param fe number forge energy value
---@param combine_label boolean if a label should be included in the string itself
---@param format string format override
---@param combine_label? boolean if a label should be included in the string itself
---@param format? string format override
---@return string str, string? unit
function util.power_format(fe, combine_label, format)
local unit
@ -378,21 +381,30 @@ function util.power_format(fe, combine_label, format)
format = "%.2f"
end
if fe < 1000 then
if fe < 1000.0 then
unit = "FE"
value = fe
elseif fe < 1000000 then
elseif fe < 1000000.0 then
unit = "kFE"
value = kFE(fe)
elseif fe < 1000000000 then
elseif fe < 1000000000.0 then
unit = "MFE"
value = MFE(fe)
elseif fe < 1000000000000 then
elseif fe < 1000000000000.0 then
unit = "GFE"
value = GFE(fe)
else
elseif fe < 1000000000000000.0 then
unit = "TFE"
value = TFE(fe)
elseif fe < 1000000000000000000.0 then
unit = "PFE"
value = PFE(fe)
elseif fe < 1000000000000000000000.0 then
unit = "EFE"
value = EFE(fe)
else
unit = "ZFE"
value = ZFE(fe)
end
if combine_label then