This commit is contained in:
Baipyrus 2023-10-31 15:11:07 +01:00
parent eefe2a5721
commit d4fbdca039
2 changed files with 12 additions and 4 deletions

View File

@ -34,7 +34,7 @@ function generate_message(buffer)
-- format and align reactor status
message_aligned(buffer, 'Status....:', a_raw and 'ACTIVE' or 'OFFLINE', system.width)
message_aligned(buffer, 'Damage....:', format_percent(options, d_raw), system.width)
message_aligned(buffer, 'Damage....:', format_percent(options, d_raw, false), system.width)
-- format and align reactor internal battery
message(buffer, '\n')

View File

@ -39,8 +39,14 @@ function format_energy(options, number, transfer)
end
-- format percentages as number with two decimals and padded unit
function format_percent(options, number)
return string.format('%.2f', number * 100) .. ' % ' .. string.rep(' ', #options.unit)
function format_percent(options, number, mult)
-- multiply by default
local percent = number
if mult or true then
percent = number * 100
end
return string.format('%.2f ', percent) .. '% ' .. string.rep(' ', #options.unit)
end
-- format temperature as number with two decimals and padded unit
@ -49,7 +55,7 @@ function format_temp(options, number)
-- compact number
if options.compact then temperature = compact_number(number)
else temperature = string.format('%.2f', temperature) end
else temperature = string.format('%.2f ', temperature) end
-- build string
return temperature .. 'K ' .. string.rep(' ', #options.unit)
@ -62,6 +68,8 @@ function format_liquid(options, number, transfer)
-- compact number
if options.compact then
liquid = compact_number(number)
else
liquid = liquid .. ' '
end
-- append transfer unit