76 lines
1.9 KiB
Lua
76 lines
1.9 KiB
Lua
local kernel = require("kernel")
|
|
local reactor = peripheral.find("fissionReactorLogicAdapter")
|
|
local monitor = peripheral.find("monitor")
|
|
local tempDriver = kernel.addDriver("temperature_driver")
|
|
local coolantDriver = kernel.addDriver("coolant_driver")
|
|
|
|
local function runMonitors()
|
|
while true do
|
|
tempDriver.watch(reactor, monitor)
|
|
coolantDriver.watch(reactor, monitor)
|
|
end
|
|
end
|
|
|
|
local function runDisplay()
|
|
monitor.clear()
|
|
monitor.setTextScale(1)
|
|
while true do
|
|
monitor.setCursorPos(1, 1)
|
|
|
|
local drivers = {
|
|
{ Label = "Temperature", driver = tempDriver },
|
|
{ Label = "Coolant", driver = coolantDriver },
|
|
}
|
|
|
|
for i, item in ipairs(drivers) do
|
|
monitor.setCursorPos(1, i)
|
|
monitor.clearLine()
|
|
item.driver.report(reactor, monitor)
|
|
monitor.setCursorPos(1, i + 1)
|
|
end
|
|
|
|
sleep(0.25) -- Update every quarter second
|
|
end
|
|
end
|
|
|
|
local function run()
|
|
while not reactor do
|
|
print("Waiting for reactor signal...")
|
|
sleep(1)
|
|
end
|
|
|
|
while not monitor do
|
|
print("Waiting for monitor signal...")
|
|
sleep(1)
|
|
end
|
|
|
|
parallel.waitForAll(runMonitors, runDisplay)
|
|
end
|
|
|
|
return { run = run}
|
|
|
|
-- local monitor = peripheral.wrap("top")
|
|
-- local modem = peripheral.wrap("back")
|
|
-- print(monitor)
|
|
-- monitor.clear()
|
|
-- monitor.setTextScale(1)
|
|
-- local maxWidth, maxHeight = monitor.getSize()
|
|
-- local y = 1
|
|
-- monitor.setCursorPos(1, y)
|
|
-- local init = "Initalizing stream...."
|
|
-- monitor.write(init)
|
|
-- print(init)
|
|
-- y = y+1
|
|
-- modem.open(80)
|
|
|
|
-- while true do
|
|
-- local _, _, _, _, message = os.pullEvent("modem_message")
|
|
-- monitor.setCursorPos(1, y)
|
|
-- print(message)
|
|
-- monitor.write(message)
|
|
-- y=y+1
|
|
-- if(y > maxHeight) then
|
|
-- y=maxHeight
|
|
-- monitor.scroll(1)
|
|
-- end
|
|
-- end |