Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[TODO LIST
- 01 DONE Catch errors when no modem/monitor are found. Currently it just crashes the program
- 02 TODO Add instructions
- ]]
- function Main()
- local netPos = FindPeripheral("modem")
- if netPos == null then print("Error: No modem detected.") sleep(5) break end
- Display("Running 'Monitor'")
- rednet.open(netPos)
- while true do
- local ID,message = rednet.receive()
- print(message)
- Display(message,monPos)
- sleep(1)
- end
- rednet.close(netPos)
- end
- function Display(text)
- local monPos = FindPeripheral("monitor")
- if monPos == null then print("Error: No monitor detected.") sleep(5) break end
- local mon = peripheral.wrap(monPos)
- mon.scroll(-1)
- mon.setCursorPos(1,1)
- mon.write(text)
- end
- function FindPeripheral(peripheralType)
- if peripheral.getType("right") == peripheralType then return "right" end
- if peripheral.getType("left") == peripheralType then return "left" end
- if peripheral.getType("top") == peripheralType then return "top" end
- if peripheral.getType("bottom") == peripheralType then return "bottom" end
- if peripheral.getType("front") == peripheralType then return "front" end
- if peripheral.getType("back") == peripheralType then return "back" end
- end
- Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement