added status driver
This commit is contained in:
3
main.lua
3
main.lua
@@ -3,11 +3,13 @@ local reactor = peripheral.find("fissionReactorLogicAdapter")
|
|||||||
local monitor = peripheral.find("monitor")
|
local 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 function runMonitors()
|
local function runMonitors()
|
||||||
while true do
|
while true do
|
||||||
tempDriver.watch(reactor, monitor)
|
tempDriver.watch(reactor, monitor)
|
||||||
coolantDriver.watch(reactor, monitor)
|
coolantDriver.watch(reactor, monitor)
|
||||||
|
statusDriver.watch(reactor, monitor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -18,6 +20,7 @@ local function runDisplay()
|
|||||||
monitor.setCursorPos(1, 1)
|
monitor.setCursorPos(1, 1)
|
||||||
|
|
||||||
local drivers = {
|
local drivers = {
|
||||||
|
{ Label = "Status", driver = statusDriver },
|
||||||
{ Label = "Temperature", driver = tempDriver },
|
{ Label = "Temperature", driver = tempDriver },
|
||||||
{ Label = "Coolant", driver = coolantDriver },
|
{ Label = "Coolant", driver = coolantDriver },
|
||||||
}
|
}
|
||||||
|
|||||||
23
status_driver.lua
Normal file
23
status_driver.lua
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
local function getValue(reactor)
|
||||||
|
return reactor.Status() 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(1)
|
||||||
|
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 }
|
||||||
Reference in New Issue
Block a user