added status driver

This commit is contained in:
2025-06-14 14:16:32 -04:00
parent 660a5ae85a
commit 28203cac8b
2 changed files with 26 additions and 0 deletions

View File

@@ -3,11 +3,13 @@ local reactor = peripheral.find("fissionReactorLogicAdapter")
local monitor = peripheral.find("monitor") local monitor = peripheral.find("monitor")
local tempDriver = kernel.addDriver("temperature_driver") local tempDriver = kernel.addDriver("temperature_driver")
local coolantDriver = kernel.addDriver("coolant_driver") local coolantDriver = kernel.addDriver("coolant_driver")
local statusDriver = kernel.addDriver("status_driver")
local function runMonitors() local function runMonitors()
while true do while true do
tempDriver.watch(reactor, monitor) tempDriver.watch(reactor, monitor)
coolantDriver.watch(reactor, monitor) coolantDriver.watch(reactor, monitor)
statusDriver.watch(reactor, monitor)
end end
end end
@@ -18,6 +20,7 @@ local function runDisplay()
monitor.setCursorPos(1, 1) monitor.setCursorPos(1, 1)
local drivers = { local drivers = {
{ Label = "Status", driver = statusDriver },
{ Label = "Temperature", driver = tempDriver }, { Label = "Temperature", driver = tempDriver },
{ Label = "Coolant", driver = coolantDriver }, { Label = "Coolant", driver = coolantDriver },
} }

23
status_driver.lua Normal file
View File

@@ -0,0 +1,23 @@
local function getValue(reactor)
return reactor.Status() or false
end
local function color(reactor)
local value = getValue(reactor)
return colors.black
end
local function watch(reactor, monitor)
print("Status: " .. getValue(reactor))
sleep(1)
end
local function report(reactor, monitor)
local value = getValue(reactor)
local color = color(reactor)
monitor.setBackgroundColor(color)
monitor.clearLine()
monitor.write("Reactor Status: " .. tostring(value))
end
return { report = report, watch = watch }