formatting temperatures
This commit is contained in:
parent
63bf3b01a4
commit
4095189450
|
@ -43,6 +43,18 @@ function format_percent(options, number)
|
|||
return string.format('%.2f', number * 100) .. ' % ' .. string.rep(' ', #options.unit)
|
||||
end
|
||||
|
||||
-- format temperature as number with two decimals and padded unit
|
||||
function format_temp(options, number)
|
||||
local temperature = number
|
||||
|
||||
-- compact number
|
||||
if options.compact then temperature = compact_number(number)
|
||||
else temperature = string.format('%.2f', temperature) end
|
||||
|
||||
-- build string
|
||||
return temperature .. ' K ' .. string.rep(' ', #options.unit)
|
||||
end
|
||||
|
||||
function find_peripheral_component(name)
|
||||
for _, side in pairs(peripheral.getNames()) do
|
||||
if peripheral.getType(side) == name then
|
||||
|
|
Loading…
Reference in New Issue
Block a user