Jackson_Pike

Monitor

Nov 16th, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.40 KB | None | 0 0
  1. modem = peripheral.wrap("left")
  2. monitor = peripheral.wrap("back")
  3. modem.open(1)
  4.  
  5. event, side, xpos, ypos = os.pullEvent("monitor_touch")
  6. if event == "monitor_touch" then
  7. modem.transmit(1, 1, "toggle")
  8. --print(event)
  9. end
  10. event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  11. if message == "ON" then
  12. monitor.setBackgroundColor(colors.black)
  13. monitor.clear()
  14. --monitor.setTextScale(1)
  15. monX, monY = monitor.getSize()
  16. monitor.setCursorPos(1, 1)
  17. monitor.setBackgroundColor(colors.red)
  18. monitor.write(string.rep(" ", monX))
  19. monitor.setCursorPos(1, monY)
  20. monitor.write(string.rep(" ", monX))
  21. monitor.setBackgroundColor(colors.black)
  22. monitor.setTextColor(colors.red)
  23. --monitor.setBackgroundColor(colors.gray)
  24. --monitor.setTextScale(2)
  25. monitor.setCursorPos(monX/2-3, 3)
  26. monitor.write("Turn Off")
  27. end
  28. if message == "OFF" then
  29. monitor.setBackgroundColor(colors.black)
  30. monitor.clear()
  31. monX, monY = monitor.getSize()
  32. --monitor.setTextScale(1)
  33. monitor.setBackgroundColor(colors.green)
  34. monitor.setCursorPos(1, 1)
  35. monitor.write(string.rep(" ", monX))
  36. monitor.setCursorPos(1, monY)
  37. monitor.write(string.rep(" ", monX))
  38. monitor.setBackgroundColor(colors.black)
  39. monitor.setTextColor(colors.green)
  40. --monitor.setBackgroundColor(colors.gray)
  41. --monitor.setTextScale(2)
  42. monitor.setCursorPos(monX/2-3, 3)
  43. monitor.write("Turn On")
  44. end
  45. sleep(0.1)
  46. shell.run("startup")
Add Comment
Please, Sign In to add comment