updated
This commit is contained in:
17
main.lua
17
main.lua
@@ -1,5 +1,6 @@
|
||||
local kernel = require("kernel")
|
||||
local reactor = peripheral.find("fissionReactorLogicAdapter")
|
||||
local turbine = peripheral.find("turbineValve")
|
||||
local monitor = peripheral.find("monitor")
|
||||
local tempDriver = kernel.addDriver("temperature_driver")
|
||||
local coolantDriver = kernel.addDriver("coolant_driver")
|
||||
@@ -15,7 +16,7 @@ local function runMonitors()
|
||||
tempDriver.watch(reactor, monitor)
|
||||
coolantDriver.watch(reactor, monitor)
|
||||
statusDriver.watch(reactor, monitor)
|
||||
turbineDriver.watch(reactor, monitor)
|
||||
turbineDriver.watch(turbine, monitor)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,19 +33,29 @@ local function runDisplay()
|
||||
monitor.clear()
|
||||
end
|
||||
monitor.setCursorPos(1, 1)
|
||||
local drivers = {
|
||||
local reactorDrivers = {
|
||||
{ Label = "Status", driver = statusDriver },
|
||||
{ Label = "Temperature", driver = tempDriver },
|
||||
{ Label = "Coolant", driver = coolantDriver },
|
||||
{ Label = "Turbine", driver = turbineDriver },
|
||||
}
|
||||
|
||||
for i, item in ipairs(drivers) do
|
||||
for i, item in ipairs(reactorDrivers) do
|
||||
monitor.setCursorPos(1, i)
|
||||
item.driver.report(reactor, monitor)
|
||||
monitor.setCursorPos(1, i + 1)
|
||||
end
|
||||
|
||||
local turbineDrivers = {
|
||||
{ Label = "Turbine", driver = turbineDriver }
|
||||
}
|
||||
|
||||
for i, item in ipairs(turbineDrivers) do
|
||||
monitor.setCursorPos(1, i)
|
||||
item.driver.report(turbine, monitor)
|
||||
monitor.setCursorPos(1, i + 1)
|
||||
end
|
||||
|
||||
sleep(0.25) -- Update every quarter second
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
local function getValue(reactor)
|
||||
return reactor.getSteamFilledPercentage() * 100
|
||||
local function getValue(target)
|
||||
return target.getSteamFilledPercentage() * 100
|
||||
end
|
||||
|
||||
local function color(reactor)
|
||||
local value = getValue(reactor)
|
||||
local function color(target)
|
||||
local value = getValue(target)
|
||||
return colors.black
|
||||
end
|
||||
|
||||
local function watch(reactor, monitor)
|
||||
print("Turbine Steam Filled: " .. getValue(reactor))
|
||||
local function watch(target, monitor)
|
||||
print("Turbine Steam Filled: " .. getValue(target))
|
||||
end
|
||||
|
||||
local function report(reactor, monitor)
|
||||
local color = color(reactor)
|
||||
local function report(target, monitor)
|
||||
local color = color(target)
|
||||
monitor.setBackgroundColor(color)
|
||||
monitor.clearLine()
|
||||
monitor.write("Turbine Steam Filled: " .. getValue(reactor) .. "%")
|
||||
monitor.write("Turbine Steam Filled: " .. getValue(target) .. "%")
|
||||
end
|
||||
return { report = report, watch = watch }
|
||||
Reference in New Issue
Block a user