25 lines
691 B
Lua
25 lines
691 B
Lua
|
|
local function getValue(reactor)
|
|
local kelvin = reactor.getTemperature() or 0
|
|
local fahrenheit = (kelvin - 273.15) * 9 / 5 + 32
|
|
return math.floor(fahrenheit * 10000 + 0.5) / 10000
|
|
end
|
|
|
|
local function color(reactor)
|
|
local temperature = getValue(reactor)
|
|
return colors.black
|
|
end
|
|
|
|
local function watch(reactor, monitor)
|
|
print("Temperature: " .. getValue(reactor))
|
|
sleep(1)
|
|
end
|
|
|
|
local function report(reactor, monitor)
|
|
local value = getValue(reactor)
|
|
local color = color(reactor)
|
|
monitor.setBackgroundColor(color)
|
|
monitor.clearLine()
|
|
monitor.write("Temperature: " .. value .. "F")
|
|
end
|
|
return { report = report, watch = watch } |