formatting liquids

This commit is contained in:
Baipyrus 2023-10-29 15:16:37 +01:00
parent f4bc968c8a
commit 116d28be99
2 changed files with 7 additions and 2 deletions

View File

@ -40,8 +40,8 @@ function generate_message(buffer)
-- format and align fuel and coolant fill
message(buffer, '\n')
message_aligned(buffer, 'Fuel.....:', options.compact and compact_number(f_raw) or f_raw, system.width)
message_aligned(buffer, 'Capacity.:', options.compact and compact_number(c_raw) or c_raw, system.width)
message_aligned(buffer, 'Fuel.....:', format_liquid(options, f_raw), system.width)
message_aligned(buffer, 'Capacity.:', format_liquid(options, c_raw), system.width)
-- format and align temperatures
message(buffer, '\n')

View File

@ -55,6 +55,11 @@ function format_temp(options, number)
return temperature .. 'K ' .. string.rep(' ', #options.unit)
end
-- format liquids as compact number and padded unit
function format_liquid(options, number)
return (options.compact and compact_number(number) or number) .. 'mB' .. string.rep(' ', #options.unit)
end
function find_peripheral_component(name)
for _, side in pairs(peripheral.getNames()) do
if peripheral.getType(side) == name then