updated
This commit is contained in:
@@ -1,31 +1,25 @@
|
|||||||
local maxValue = 100
|
local maxValue = 100
|
||||||
local minValue = 0
|
local minValue = 0
|
||||||
|
|
||||||
local function getValue(reactor)
|
local function getValue()
|
||||||
return (reactor.getCoolantFilledPercentage() or 0) * 100
|
return (reactor.getCoolantFilledPercentage() or 0) * 100
|
||||||
end
|
end
|
||||||
|
|
||||||
local function configureReport(monitor)
|
local function color()
|
||||||
local x,y = monitor.getCursorPos()
|
local coolantLevel = getValue()
|
||||||
monitor.setCursorPos(x, y + 1)
|
|
||||||
monitor.clearLine()
|
|
||||||
end
|
|
||||||
|
|
||||||
local function color(reactor)
|
|
||||||
local coolantLevel = getValue(reactor)
|
|
||||||
return colors.black
|
return colors.black
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function watch(reactor, monitor)
|
local function watch()
|
||||||
local coolantLevel = getValue(reactor)
|
local coolantLevel = getValue()
|
||||||
print("Coolant: " .. coolantLevel)
|
print("Coolant: " .. coolantLevel)
|
||||||
sleep(1)
|
sleep(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function report(reactor, monitor)
|
local function report()
|
||||||
local value = getValue(reactor)
|
local value = getValue()
|
||||||
local color = color(reactor)
|
local color = color()
|
||||||
monitor.setBackgroundColor(color)
|
monitor.setBackgroundColor(color)
|
||||||
monitor.clearLine()
|
monitor.clearLine()
|
||||||
monitor.write("Coolant: " .. value .. "%")
|
monitor.write("Coolant: " .. value .. "%")
|
||||||
|
|||||||
21
main.lua
21
main.lua
@@ -1,7 +1,10 @@
|
|||||||
local kernel = require("kernel")
|
local kernel = require("kernel")
|
||||||
local reactor = peripheral.find("fissionReactorLogicAdapter")
|
|
||||||
local turbine = peripheral.find("turbineValve")
|
reactor = peripheral.find("fissionReactorLogicAdapter")
|
||||||
local monitor = peripheral.find("monitor")
|
turbine = peripheral.find("turbineValve")
|
||||||
|
turbineVent = peripheral.find("turbineVent")
|
||||||
|
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 statusDriver = kernel.addDriver("status_driver")
|
||||||
@@ -22,7 +25,7 @@ end
|
|||||||
|
|
||||||
local function runDisplay()
|
local function runDisplay()
|
||||||
monitor.clear()
|
monitor.clear()
|
||||||
monitor.setTextScale(1)
|
monitor.setTextScale(0.75)
|
||||||
while true do
|
while true do
|
||||||
if(isWarningState or isCriticalState or isShutdownState) then
|
if(isWarningState or isCriticalState or isShutdownState) then
|
||||||
monitor.setBackgroundColor(colors.red)
|
monitor.setBackgroundColor(colors.red)
|
||||||
@@ -34,15 +37,15 @@ local function runDisplay()
|
|||||||
end
|
end
|
||||||
monitor.setCursorPos(1, 1)
|
monitor.setCursorPos(1, 1)
|
||||||
local drivers = {
|
local drivers = {
|
||||||
{ Label = "Status", driver = statusDriver, peripheral = reactor },
|
{ Label = "Status", driver = statusDriver},
|
||||||
{ Label = "Temperature", driver = tempDriver, peripheral = reactor },
|
{ Label = "Temperature", driver = tempDriver },
|
||||||
{ Label = "Coolant", driver = coolantDriver, peripheral = reactor },
|
{ Label = "Coolant", driver = coolantDriver },
|
||||||
{ Label = "Turbine", driver = turbineDriver, peripheral = turbine }
|
{ Label = "Turbine", driver = turbineDriver }
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, item in ipairs(drivers) do
|
for i, item in ipairs(drivers) do
|
||||||
monitor.setCursorPos(1, i)
|
monitor.setCursorPos(1, i)
|
||||||
item.driver.report(item.peripheral, monitor)
|
item.driver.report()
|
||||||
monitor.setCursorPos(1, i + 1)
|
monitor.setCursorPos(1, i + 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
|
|
||||||
local function getValue(reactor)
|
local function getValue()
|
||||||
return reactor.getStatus() or false
|
return reactor.getStatus() or false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function color(reactor)
|
local function color()
|
||||||
local value = getValue(reactor)
|
local value = getValue()
|
||||||
return colors.black
|
return colors.black
|
||||||
end
|
end
|
||||||
|
|
||||||
local function watch(reactor, monitor)
|
local function watch()
|
||||||
local value = getValue(reactor)
|
local value = getValue()
|
||||||
print("Status: " .. tostring(value))
|
print("Status: " .. tostring(value))
|
||||||
sleep(1)
|
sleep(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function report(reactor, monitor)
|
local function report()
|
||||||
local value = getValue(reactor)
|
local value = getValue()
|
||||||
local color = color(reactor)
|
local color = color()
|
||||||
monitor.setBackgroundColor(color)
|
monitor.setBackgroundColor(color)
|
||||||
monitor.clearLine()
|
monitor.clearLine()
|
||||||
monitor.write("Reactor Status: " .. tostring(value))
|
monitor.write("Reactor Status: " .. tostring(value))
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
|
|
||||||
local function getValue(reactor)
|
local function getValue()
|
||||||
local kelvin = reactor.getTemperature() or 0
|
local kelvin = reactor.getTemperature() or 0
|
||||||
local fahrenheit = (kelvin - 273.15) * 9 / 5 + 32
|
local fahrenheit = (kelvin - 273.15) * 9 / 5 + 32
|
||||||
return math.floor(fahrenheit * 10000 + 0.5) / 10000
|
return math.floor(fahrenheit * 10000 + 0.5) / 10000
|
||||||
end
|
end
|
||||||
|
|
||||||
local function color(reactor)
|
local function color()
|
||||||
local temperature = getValue(reactor)
|
local temperature = getValue()
|
||||||
return colors.black
|
return colors.black
|
||||||
end
|
end
|
||||||
|
|
||||||
local function watch(reactor, monitor)
|
local function watch()
|
||||||
print("Temperature: " .. getValue(reactor))
|
print("Temperature: " .. getValue())
|
||||||
sleep(1)
|
sleep(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function report(reactor, monitor)
|
local function report()
|
||||||
local value = getValue(reactor)
|
local value = getValue()
|
||||||
local color = color(reactor)
|
local color = color()
|
||||||
monitor.setBackgroundColor(color)
|
monitor.setBackgroundColor(color)
|
||||||
monitor.clearLine()
|
monitor.clearLine()
|
||||||
monitor.write("Temperature: " .. value .. "F")
|
monitor.write("Temperature: " .. value .. "F")
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
local function getValue(target)
|
local function getValue()
|
||||||
return target.getSteamFilledPercentage() * 100
|
return turbine.getSteamFilledPercentage() * 100
|
||||||
end
|
end
|
||||||
|
|
||||||
local function color(target)
|
local function color()
|
||||||
local value = getValue(target)
|
local value = getValue()
|
||||||
return colors.black
|
return colors.black
|
||||||
end
|
end
|
||||||
|
|
||||||
local function watch(target, monitor)
|
local function watch()
|
||||||
print("Turbine Steam Filled: " .. getValue(target))
|
print("Turbine Steam Filled: " .. getValue())
|
||||||
end
|
end
|
||||||
|
|
||||||
local function report(target, monitor)
|
local function report()
|
||||||
local color = color(target)
|
local color = color()
|
||||||
monitor.setBackgroundColor(color)
|
monitor.setBackgroundColor(color)
|
||||||
monitor.clearLine()
|
monitor.clearLine()
|
||||||
monitor.write("Turbine Steam Filled: " .. getValue(target) .. "%")
|
monitor.write("Turbine Steam Filled: " .. getValue() .. "%")
|
||||||
end
|
end
|
||||||
return { report = report, watch = watch }
|
return { report = report, watch = watch }
|
||||||
Reference in New Issue
Block a user