Advertisement
Entityreborn

Monitor

Apr 26th, 2015
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.22 KB | None | 0 0
  1. --[[ startup
  2. id="Hxm08R4U"
  3. loadstring(http.get("http://pastebin.com/raw.php?i=" .. id).readAll())()
  4. ]]--
  5.  
  6. connected = false
  7. modem = false
  8. monitor = false
  9. debugmon = false
  10. glass = false
  11. myChannel = 6637
  12.  
  13. function writeLine(message)
  14.     monitor.write(message)
  15.     local _,cY= monitor.getCursorPos()
  16.     monitor.setCursorPos(1,cY+1)
  17. end
  18.  
  19. if (peripheral.getType("left") == 'modem') then
  20.     print("Found modem, attaching to " .. myChannel)
  21.     modem = peripheral.wrap("left")
  22.     modem.open(myChannel)
  23.     connected = true
  24. end
  25.    
  26. if (peripheral.getType("back") == 'monitor') then
  27.     print("Found main monitor.")
  28.     monitor = peripheral.wrap("back")
  29.     monitor.clear()
  30.     monitor.setCursorPos(1,1)
  31.     monitor.setTextScale(0.8)
  32. end
  33.  
  34. if (peripheral.getType("right") == 'monitor') then
  35.     print("Found debug monitor.")
  36.     print("Redirecting output.")
  37.     debugmon = peripheral.wrap("right")
  38.     debugmon.clear()
  39.     debugmon.setCursorPos(1,1)
  40.     debugmon.setTextScale(0.5)
  41.     term.redirect(debugmon, false)
  42. end
  43.  
  44. print("Hold CTRL-T for one second to stop, CTRL-R to reboot and update.")
  45. writeLine("Booted.")
  46.  
  47. while connected do
  48.     local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  49.     writeLine(message)
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement