Files
nova-corp/temperature_driver.lua
2025-06-15 16:23:13 -04:00

50 lines
1.2 KiB
Lua

local max = 300
local min = 275
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 checkTemperature()
local temperature = getValue()
local upperThreshold = max - 1
local lowerThreshold = min + 1
if temperature >= upperThreshold then
print("Warning: Temperature approaching upper limit! Taking action.")
burnRateDriver.stepDown()
elseif temperature <= lowerThreshold then
print("Warning: Temperature approaching lower limit! Taking action.")
burnRateDriver.slowStepUp()
end
end
local function watch()
while true do
print("Temperature: " .. getValue())
checkTemperature()
sleep(0.05) -- Update every tenth second
end
end
local function startUp()
end
local function shutdown()
end
local function report()
local value = getValue()
local color = colors.black
monitor.setBackgroundColor(color)
setNewLine()
monitor.write("Temperature: " .. value .. "F")
end
return { report = report, watch = watch, startUp = startUp, shutdown = shutdown }