Files
nova-corp/temperature_driver.lua
2025-06-14 15:22:05 -04:00

25 lines
617 B
Lua

local function getValue()
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()
local temperature = getValue()
return colors.black
end
local function watch()
print("Temperature: " .. getValue())
sleep(1)
end
local function report()
local value = getValue()
local color = color()
monitor.setBackgroundColor(color)
monitor.clearLine()
monitor.write("Temperature: " .. value .. "F")
end
return { report = report, watch = watch }