This commit is contained in:
2025-06-15 16:23:13 -04:00
parent dcb75ee52c
commit ead0e6379e
9 changed files with 118 additions and 108 deletions

View File

@@ -8,19 +8,6 @@ local function getValue()
return reactor.getBurnRate() or init return reactor.getBurnRate() or init
end 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 function stepUp()
local value = getValue() local value = getValue()
@@ -49,17 +36,22 @@ local function stepDown()
reactor.setBurnRate(value - rateStep) reactor.setBurnRate(value - rateStep)
end end
end end
local function startUp()
end
local function shutdown()
end
local function watch() local function watch()
print("Setting Default Burn Rate to: " .. init) print("Setting Default Burn Rate to: " .. init)
reactor.setBurnRate(init) reactor.setBurnRate(init)
end end
local function report() local function report()
local color = color() local color = colors.black
monitor.setBackgroundColor(color) monitor.setBackgroundColor(color)
value = getValue() value = getValue()
monitor.clearLine()
setNewLine()
monitor.write("Burn Rate: " .. value) monitor.write("Burn Rate: " .. value)
end end
return { report = report, watch = watch, stepUp = stepUp, stepDown = stepDown, slowStepDown = slowStepDown, slowStepUp = slowStepUp } return { report = report, watch = watch, stepUp = stepUp, stepDown = stepDown, slowStepDown = slowStepDown, slowStepUp = slowStepUp, startUp = startUp, shutdown = shutdown }

View File

@@ -30,17 +30,21 @@ local function watch()
end end
end end
-- local function watch()
-- checkCoolantLevel() local function startUp()
-- end end
local function shutdown()
end
local function report() local function report()
local value = getValue() local value = getValue()
local color = colors.black local color = colors.black
monitor.setBackgroundColor(color) monitor.setBackgroundColor(color)
monitor.clearLine()
setNewLine()
monitor.write("Coolant: " .. value .. "%") monitor.write("Coolant: " .. value .. "%")
end end
return { report = report, watch = watch} return { report = report, watch = watch, startUp = startUp, shutdown = shutdown }

26
environment_driver.lua Normal file
View File

@@ -0,0 +1,26 @@
local function getValue()
return environment.getRadiationLevel().radiation
end
local function watch()
while true do
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("Radiation Level: " .. tostring(value))
end
return { report = report, watch = watch, startUp = startUp, shutdown = shutdown }

View File

@@ -1,27 +0,0 @@
modem = peripheral.wrap("right")
environment = peripheral.wrap("left")
local function runMonitor()
while true do
local rads = environment.getRadiation();
print("Radiation Level: " .. rads.radiation)
print("Radiation Unit: " .. rads.unit)
sleep(1)
end
end
local function run()
while not modem do
print("Waiting for modem signal...")
sleep(1)
end
while not environment do
print("Waiting for environment signal...")
sleep(1)
end
parallel.waitForAll(runMonitor)
end
return { run = run}

View File

@@ -1,4 +0,0 @@
local kernel = require("kernel")
local main = kernel.addDriver("environment_main")
sleep(5)
main.run()

View File

@@ -3,48 +3,72 @@ reactor = peripheral.find("fissionReactorLogicAdapter")
turbine = peripheral.find("turbineValve") turbine = peripheral.find("turbineValve")
turbineVent = peripheral.find("turbineVent") turbineVent = peripheral.find("turbineVent")
monitor = peripheral.find("monitor") monitor = peripheral.find("monitor")
environment = peripheral.find("environmentDetector")
tempDriver = kernel.addDriver("temperature_driver") tempDriver = kernel.addDriver("temperature_driver")
coolantDriver = kernel.addDriver("coolant_driver") coolantDriver = kernel.addDriver("coolant_driver")
statusDriver = kernel.addDriver("status_driver") statusDriver = kernel.addDriver("status_driver")
turbineDriver = kernel.addDriver("turbine_driver") turbineDriver = kernel.addDriver("turbine_driver")
burnRateDriver = kernel.addDriver("burnrate_driver") burnRateDriver = kernel.addDriver("burnrate_driver")
environmentDriver = kernel.addDriver("environment_driver")
function setNewLine()
local x,y = monitor.getCursorPos()
monitor.setCursorPos(1, y + 1)
monitor.clearLine()
end
local function runMonitors() local function runMonitors()
parallel.waitForAll(tempDriver.watch, coolantDriver.watch, statusDriver.watch, turbineDriver.watch, burnRateDriver.watch) parallel.waitForAll(
-- while true do tempDriver.watch,
-- tempDriver.watch() coolantDriver.watch,
-- coolantDriver.watch() statusDriver.watch,
-- statusDriver.watch() turbineDriver.watch,
-- turbineDriver.watch() burnRateDriver.watch,
-- burnRateDriver.watch() environmentDriver.watch)
-- sleep(0.05)
-- end
end end
local function runDisplay() local function runDisplay()
monitor.clear() monitor.clear()
monitor.setTextScale(1) monitor.setTextScale(1)
while true do while true do
monitor.setCursorPos(1, 1) monitor.setCursorPos(1, 0)
local drivers = { local drivers = {
{ Label = "Status", driver = statusDriver}, { Label = "Status", driver = statusDriver},
{ Label = "Temperature", driver = tempDriver }, { Label = "Temperature", driver = tempDriver },
{ Label = "Coolant", driver = coolantDriver }, { Label = "Coolant", driver = coolantDriver },
{ Label = "Turbine", driver = turbineDriver }, { Label = "Turbine", driver = turbineDriver },
{ Label = "Burn Rate", driver = burnRateDriver } { Label = "Burn Rate", driver = burnRateDriver },
{ Label = "Radiation Level", driver = burnRateDriver }
} }
for i, item in ipairs(drivers) do for i, item in ipairs(drivers) do
monitor.setCursorPos(1, i)
item.driver.report() item.driver.report()
monitor.setCursorPos(1, i + 1)
end end
sleep(0.05) -- Update every tenth second sleep(0.05) -- Update every tenth second
end end
end end
local function startUp()
parallel.waitForAll(tempDriver.startUp,
coolantDriver.startUp,
statusDriver.startUp,
turbineDriver.startUp,
burnRateDriver.startUp,
environmentDriver.startUp)
end
local function shutDown()
parallel.waitForAll(tempDriver.shutDown,
coolantDriver.shutDown,
statusDriver.shutDown,
turbineDriver.shutDown,
burnRateDriver.shutDown,
environmentDriver.shutDown)
end
local function run() local function run()
while not reactor do while not reactor do
print("Waiting for reactor signal...") print("Waiting for reactor signal...")
@@ -59,13 +83,11 @@ local function run()
sleep(1) sleep(1)
end end
-- Wait for all driver objects to be available
while not (tempDriver and coolantDriver and statusDriver and turbineDriver and burnRateDriver) do
print("Waiting for all drivers to be initialized...")
sleep(1)
end
monitor.clear(); monitor.clear();
startUp();
parallel.waitForAll(runMonitors, runDisplay) parallel.waitForAll(runMonitors, runDisplay)
end end
return { run = run}
return { run = run }

View File

@@ -4,41 +4,37 @@ local function getValue()
end end
-- local function watch()
-- while true do
-- checkStatus()
-- sleep(0.05) -- Update every tenth second
-- end
-- end
local function checkStatus() local function checkStatus()
local value = getValue() local value = getValue()
end end
-- local function watch()
-- checkStatus()
-- end
local function watch() local function watch()
reactor.setBurnRate(2)
local status = reactor.getStatus()
if(not status) then
reactor.activate()
return
end
while true do while true do
checkStatus() checkStatus()
sleep(0.05) -- Update every tenth second sleep(0.05) -- Update every tenth second
end end
end end
local function startUp()
reactor.setBurnRate(2)
local status = reactor.getStatus()
if(not status) then
reactor.activate()
return
end
end
local function shutdown()
reactor.setBurnRate(0)
reactor.deactivate()
end
local function report() local function report()
local value = getValue() local value = getValue()
local color = colors.black local color = colors.black
monitor.setBackgroundColor(color) monitor.setBackgroundColor(color)
monitor.clearLine()
setNewLine()
monitor.write("Reactor Status: " .. tostring(value)) monitor.write("Reactor Status: " .. tostring(value))
end end
return { report = report, watch = watch } return { report = report, watch = watch, startUp = startUp, shutdown = shutdown }

View File

@@ -22,13 +22,8 @@ local function checkTemperature()
end end
end end
-- local function color()
-- local temperature = getValue()
-- return colors.black
-- end
local function watch() local function watch()
while true do while true do
print("Temperature: " .. getValue()) print("Temperature: " .. getValue())
checkTemperature() checkTemperature()
@@ -37,18 +32,19 @@ local function watch()
end end
local function startUp()
end
local function shutdown()
end
-- local function watch()
-- checkTemperature()
-- end
local function report() local function report()
local value = getValue() local value = getValue()
local color = colors.black local color = colors.black
monitor.setBackgroundColor(color) monitor.setBackgroundColor(color)
monitor.clearLine()
setNewLine()
monitor.write("Temperature: " .. value .. "F") monitor.write("Temperature: " .. value .. "F")
end end
return { report = report, watch = watch } return { report = report, watch = watch, startUp = startUp, shutdown = shutdown }

View File

@@ -35,9 +35,11 @@ local function checkSteamLevel()
end end
end end
-- local function watch() local function startUp()
-- checkSteamLevel() end
-- end
local function shutdown()
end
local function watch() local function watch()
while true do while true do
@@ -50,9 +52,12 @@ local function report()
local color = color() local color = color()
monitor.setBackgroundColor(color) monitor.setBackgroundColor(color)
value = getValue() value = getValue()
monitor.clearLine()
setNewLine()
monitor.write("Turbine Steam: " .. value .. "%") monitor.write("Turbine Steam: " .. value .. "%")
--monitor.write("Turbine Vent: " .. turbine.getDumpingMode() .. "%")
setNewLine()
monitor.write("Turbine Vent: " .. turbine.getDumpingMode())
end end
return { report = report, watch = watch } return { report = report, watch = watch, startUp = startUp, shutdown = shutdown }