50 lines
1.2 KiB
Lua
50 lines
1.2 KiB
Lua
local maxValue = 80
|
|
local minValue = 50
|
|
local minCoolant = 30
|
|
|
|
local function getValue()
|
|
return (reactor.getCoolantFilledPercentage() or 1) * 100
|
|
end
|
|
|
|
local function checkCoolantLevel()
|
|
local coolantLevel = getValue()
|
|
if coolantLevel > maxValue then
|
|
-- Do nothing if coolant is above the max value
|
|
elseif coolantLevel > minValue then
|
|
-- print("Coolant approaching minimum, slowly stepping down burn rate.")
|
|
-- burnRateDriver.slowStepDown()
|
|
elseif coolantLevel <= minCoolant then
|
|
print("Critical Warning: Coolant below minimum safe level! SCRAMMING reactor.")
|
|
reactor.scram()
|
|
elseif coolantLevel <= minValue then
|
|
print("Warning: Coolant below minimum! Stepping down burn rate.")
|
|
burnRateDriver.stepDown()
|
|
end
|
|
return true
|
|
end
|
|
|
|
local function watch()
|
|
while true do
|
|
checkCoolantLevel()
|
|
sleep(0.05)
|
|
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("Coolant: " .. value .. "%")
|
|
end
|
|
|
|
|
|
return { report = report, watch = watch, startup = startup, shutdown = shutdown } |