Files
nova-corp/burnrate_driver.lua
2025-06-14 18:36:48 -04:00

51 lines
992 B
Lua

local max = 15
local init = 3
local rateStep = 0.10
local min = 1
local function getValue()
return reactor.getBurnRate() or init
end
local function color()
local value = getValue()
return colors.black
end
local function watch()
while true do
sleep(0.05) -- Update every tenth second
end
end
local function stepUp()
local value = getValue()
if value < max then
reactor.setBurnRate(value + rateStep)
end
end
local function stepDown()
local value = getValue()
if value > min then
reactor.setBurnRate(value - rateStep)
end
end
local function watch()
print("Setting Default Burn Rate to: " .. init)
reactor.setBurnRate(init)
end
local function report()
local color = color()
monitor.setBackgroundColor(color)
value = getValue()
monitor.clearLine()
monitor.write("Burn Rate: " .. value)
end
return { report = report, watch = watch, stepUp = stepUp, stepDown = stepDown }