From 495de6bf3eb2767f6af12bdea925af49ff36f158 Mon Sep 17 00:00:00 2001 From: itzmarkoni Date: Sat, 14 Jun 2025 15:22:05 -0400 Subject: [PATCH] updated --- coolant_driver.lua | 22 ++++++++-------------- main.lua | 21 ++++++++++++--------- status_driver.lua | 16 ++++++++-------- temperature_driver.lua | 16 ++++++++-------- turbine_driver.lua | 18 +++++++++--------- 5 files changed, 45 insertions(+), 48 deletions(-) diff --git a/coolant_driver.lua b/coolant_driver.lua index c1fd58e..d06b38d 100644 --- a/coolant_driver.lua +++ b/coolant_driver.lua @@ -1,31 +1,25 @@ local maxValue = 100 local minValue = 0 -local function getValue(reactor) +local function getValue() return (reactor.getCoolantFilledPercentage() or 0) * 100 end -local function configureReport(monitor) - local x,y = monitor.getCursorPos() - monitor.setCursorPos(x, y + 1) - monitor.clearLine() -end - -local function color(reactor) - local coolantLevel = getValue(reactor) +local function color() + local coolantLevel = getValue() return colors.black end -local function watch(reactor, monitor) - local coolantLevel = getValue(reactor) +local function watch() + local coolantLevel = getValue() print("Coolant: " .. coolantLevel) sleep(1) end -local function report(reactor, monitor) - local value = getValue(reactor) - local color = color(reactor) +local function report() + local value = getValue() + local color = color() monitor.setBackgroundColor(color) monitor.clearLine() monitor.write("Coolant: " .. value .. "%") diff --git a/main.lua b/main.lua index b49218b..16fc735 100644 --- a/main.lua +++ b/main.lua @@ -1,7 +1,10 @@ local kernel = require("kernel") -local reactor = peripheral.find("fissionReactorLogicAdapter") -local turbine = peripheral.find("turbineValve") -local monitor = peripheral.find("monitor") + +reactor = peripheral.find("fissionReactorLogicAdapter") +turbine = peripheral.find("turbineValve") +turbineVent = peripheral.find("turbineVent") +monitor = peripheral.find("monitor") + local tempDriver = kernel.addDriver("temperature_driver") local coolantDriver = kernel.addDriver("coolant_driver") local statusDriver = kernel.addDriver("status_driver") @@ -22,7 +25,7 @@ end local function runDisplay() monitor.clear() - monitor.setTextScale(1) + monitor.setTextScale(0.75) while true do if(isWarningState or isCriticalState or isShutdownState) then monitor.setBackgroundColor(colors.red) @@ -34,15 +37,15 @@ local function runDisplay() end monitor.setCursorPos(1, 1) local drivers = { - { Label = "Status", driver = statusDriver, peripheral = reactor }, - { Label = "Temperature", driver = tempDriver, peripheral = reactor }, - { Label = "Coolant", driver = coolantDriver, peripheral = reactor }, - { Label = "Turbine", driver = turbineDriver, peripheral = turbine } + { Label = "Status", driver = statusDriver}, + { Label = "Temperature", driver = tempDriver }, + { Label = "Coolant", driver = coolantDriver }, + { Label = "Turbine", driver = turbineDriver } } for i, item in ipairs(drivers) do monitor.setCursorPos(1, i) - item.driver.report(item.peripheral, monitor) + item.driver.report() monitor.setCursorPos(1, i + 1) end diff --git a/status_driver.lua b/status_driver.lua index 44b91a0..8015132 100644 --- a/status_driver.lua +++ b/status_driver.lua @@ -1,22 +1,22 @@ -local function getValue(reactor) +local function getValue() return reactor.getStatus() or false end -local function color(reactor) - local value = getValue(reactor) +local function color() + local value = getValue() return colors.black end -local function watch(reactor, monitor) - local value = getValue(reactor) +local function watch() + local value = getValue() print("Status: " .. tostring(value)) sleep(1) end -local function report(reactor, monitor) - local value = getValue(reactor) - local color = color(reactor) +local function report() + local value = getValue() + local color = color() monitor.setBackgroundColor(color) monitor.clearLine() monitor.write("Reactor Status: " .. tostring(value)) diff --git a/temperature_driver.lua b/temperature_driver.lua index 74245af..c1baa6d 100644 --- a/temperature_driver.lua +++ b/temperature_driver.lua @@ -1,23 +1,23 @@ -local function getValue(reactor) +local function getValue() local kelvin = reactor.getTemperature() or 0 local fahrenheit = (kelvin - 273.15) * 9 / 5 + 32 return math.floor(fahrenheit * 10000 + 0.5) / 10000 end -local function color(reactor) - local temperature = getValue(reactor) +local function color() + local temperature = getValue() return colors.black end -local function watch(reactor, monitor) - print("Temperature: " .. getValue(reactor)) +local function watch() + print("Temperature: " .. getValue()) sleep(1) end -local function report(reactor, monitor) - local value = getValue(reactor) - local color = color(reactor) +local function report() + local value = getValue() + local color = color() monitor.setBackgroundColor(color) monitor.clearLine() monitor.write("Temperature: " .. value .. "F") diff --git a/turbine_driver.lua b/turbine_driver.lua index 6aaf8ac..46c57dc 100644 --- a/turbine_driver.lua +++ b/turbine_driver.lua @@ -1,20 +1,20 @@ -local function getValue(target) - return target.getSteamFilledPercentage() * 100 +local function getValue() + return turbine.getSteamFilledPercentage() * 100 end -local function color(target) - local value = getValue(target) +local function color() + local value = getValue() return colors.black end -local function watch(target, monitor) - print("Turbine Steam Filled: " .. getValue(target)) +local function watch() + print("Turbine Steam Filled: " .. getValue()) end -local function report(target, monitor) - local color = color(target) +local function report() + local color = color() monitor.setBackgroundColor(color) monitor.clearLine() - monitor.write("Turbine Steam Filled: " .. getValue(target) .. "%") + monitor.write("Turbine Steam Filled: " .. getValue() .. "%") end return { report = report, watch = watch } \ No newline at end of file