Well, you would need parallel if you want to use the computer while running the program.
I think this should work:
local side = "top" -- the side the monitor is on
local nTime = 3 -- time between updates, in seconds
local mon
if peripheral.isPresent(side) and peripheral.getType(side) == "monitor" then
mon = peripheral.wrap(side)
else
print("Monitor not found")
return
end
local function clear()
term.clear()
term.setCursorPos(1, 1)
end
local function run()
while true do
term.redirect(mon)
clear()
print("Redstone output status list.")
for _,side in ipairs(rs.getSides()) do
print(side, " = ", (rs.getOutput(side) and "On") or "Off") -- print "On" and "Off" instead of true/false
end
term.restore()
sleep(nTime)
end
end
parallel.waitForAny(run, function() shell.run("shell") end)
And if you want it for monitoring intput, use this one:
local side = "top" -- the side the monitor is on
local mon
if peripheral.isPresent(side) and peripheral.getType(side) == "monitor" then
mon = peripheral.wrap(side)
else
print("Monitor not found")
return
end
local function clear()
term.clear()
term.setCursorPos(1, 1)
end
local function run()
while true do
term.redirect(mon)
clear()
print("Redstone input status list.")
for _,side in ipairs(rs.getSides()) do
print(side, " = ", (rs.getInput(side) and "On") or "Off") -- print "On" and "Off" instead of true/false
end
term.restore()
os.pullEvent("restone")
end
end
parallel.waitForAny(run, function() shell.run("shell") end)
It updates every time there's a change in redstone input.