Advertisement
colhaydutu

receiver

Sep 6th, 2023 (edited)
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. modemSide = "back"
  2. targetID = 4361
  3. local monitor = peripheral.wrap("right")
  4.  
  5. local function drawBar()
  6. local w, h = monitor.getSize()
  7. term.redirect(monitor)
  8.  
  9. monitor.setBackgroundColor(colors.blue)
  10. monitor.clear()
  11. monitor.setTextColor(colors.white)
  12. paintutils.drawLine(2, 2, 5, 2, colors.red)
  13. monitor.setBackgroundColor(colors.blue)
  14. monitor.setCursorPos(6, 2)
  15. monitor.write("[Rocket Gate]")
  16. paintutils.drawLine(22, 3, 22, 5, colors.red)
  17. paintutils.drawLine(23, 3, 23, 5, colors.red)
  18. paintutils.drawLine(21, 3, 21, 5, colors.red)
  19. paintutils.drawPixel(20, 6, colors.red)
  20. paintutils.drawPixel(19, 7, colors.red)
  21. paintutils.drawPixel(24, 6, colors.red)
  22. paintutils.drawPixel(25, 7, colors.red)
  23. paintutils.drawPixel(22, 2, colors.red)
  24. paintutils.drawPixel(22, 4, colors.white)
  25.  
  26.  
  27.  
  28. monitor.setCursorPos(3, 5)
  29. monitor.setBackgroundColor(colors.green)
  30. monitor.write("[Open]")
  31.  
  32. monitor.setCursorPos(10, 5)
  33. monitor.setBackgroundColor(colors.red)
  34. monitor.write("[Close]")
  35.  
  36.  
  37.  
  38.  
  39. end
  40.  
  41.  
  42. drawBar()
  43.  
  44. while true do
  45. local event, side, x, y = os.pullEvent("monitor_touch")
  46. monitor.setBackgroundColor(colors.gray)
  47.  
  48. if x >= 3 and x <= 7 and y == 5 then
  49. rednet.open(modemSide)
  50. rednet.send(targetID, "open")
  51. rednet.close(modemSide)
  52. elseif x >= 10 and x <= 17 and y == 5 then
  53. rednet.open(modemSide)
  54. rednet.send(targetID, "close")
  55. rednet.close(modemSide)
  56. end
  57.  
  58. drawBar()
  59.  
  60. os.sleep(1)
  61.  
  62. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement