updated
This commit is contained in:
@@ -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 .. "%")
|
||||
|
||||
21
main.lua
21
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
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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 }
|
||||
Reference in New Issue
Block a user