Files
nova-corp/turbine_driver.lua
2025-06-14 17:36:55 -04:00

55 lines
1.4 KiB
Lua

local max = 90
local maxVent = 70
local minVent = 30
local min = 20
local function getValue()
return turbine.getSteamFilledPercentage() * 100
end
local function color()
local value = getValue()
return colors.black
end
-- local function watch()
-- while true do
-- checkSteamLevel()
-- sleep(0.05) -- Update every tenth second
-- end
-- end
local function watch()
checkSteamLevel()
end
function checkSteamLevel()
local value = getValue()
if value > max then
print("Warning: Steam above maximum! Taking action.")
reactor.scram();
turbine.setDumpingMode("DUMPING")
burnRateDriver.stepDown()
elseif value >= minVent and value <= maxVent then
print("Steam within vent range. Adjusting vents.")
turbine.setDumpingMode("DUMPING")
burnRateDriver.stepDown()
elseif value >= min and value < minVent then
print("Steam within normal operation range.")
turbine.setDumpingMode("DUMPING")
burnRateDriver.stepDown()
elseif value < min then
print("Warning: Steam below minimum! Taking action.")
turbine.setDumpingMode("IDLE")
end
end
local function report()
local color = color()
monitor.setBackgroundColor(color)
value = getValue()
monitor.clearLine()
monitor.write("Turbine Steam: " .. value .. "%")
end
return { report = report, watch = watch }