From 472e6d6450bc14ff2dcbfd363f771a26ea9a2dd4 Mon Sep 17 00:00:00 2001 From: itzmarkoni Date: Sat, 14 Jun 2025 14:44:28 -0400 Subject: [PATCH] updated --- main.lua | 42 +++++++++++++++--------------------------- turbine_driver.lua | 23 +++++++++++++++++++++++ 2 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 turbine_driver.lua diff --git a/main.lua b/main.lua index b2205ec..d41deb4 100644 --- a/main.lua +++ b/main.lua @@ -4,12 +4,18 @@ local monitor = peripheral.find("monitor") local tempDriver = kernel.addDriver("temperature_driver") local coolantDriver = kernel.addDriver("coolant_driver") local statusDriver = kernel.addDriver("status_driver") +local turbineDriver = kernel.addDriver("turbine_driver") + +isWarningState = false +isCriticalState = false +isShutdownState = false local function runMonitors() while true do tempDriver.watch(reactor, monitor) coolantDriver.watch(reactor, monitor) statusDriver.watch(reactor, monitor) + turbineDriver.watch(reactor, monitor) end end @@ -17,12 +23,20 @@ local function runDisplay() monitor.clear() monitor.setTextScale(1) while true do + if(isWarningState or isCriticalState or isShutdownState) then + monitor.setBackgroundColor(colors.red) + monitor.clear() + monitor.setCursorPos(1, 1) + monitor.write("Reactor in critical state!") + sleep(2) + monitor.clear() + end monitor.setCursorPos(1, 1) - local drivers = { { Label = "Status", driver = statusDriver }, { Label = "Temperature", driver = tempDriver }, { Label = "Coolant", driver = coolantDriver }, + { Label = "Turbine", driver = turbineDriver }, } for i, item in ipairs(drivers) do @@ -50,29 +64,3 @@ local function run() end return { run = run} - - -- local monitor = peripheral.wrap("top") - -- local modem = peripheral.wrap("back") - -- print(monitor) - -- monitor.clear() - -- monitor.setTextScale(1) - -- local maxWidth, maxHeight = monitor.getSize() - -- local y = 1 - -- monitor.setCursorPos(1, y) - -- local init = "Initalizing stream...." - -- monitor.write(init) - -- print(init) - -- y = y+1 - -- modem.open(80) - - -- while true do - -- local _, _, _, _, message = os.pullEvent("modem_message") - -- monitor.setCursorPos(1, y) - -- print(message) - -- monitor.write(message) - -- y=y+1 - -- if(y > maxHeight) then - -- y=maxHeight - -- monitor.scroll(1) - -- end - -- end \ No newline at end of file diff --git a/turbine_driver.lua b/turbine_driver.lua new file mode 100644 index 0000000..07e6ece --- /dev/null +++ b/turbine_driver.lua @@ -0,0 +1,23 @@ +local function getValue(reactor) + return reactor.getStatus() 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(5) + isWarningState = true +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 } \ No newline at end of file