RobotBubble

ClickTurtleMenu

Nov 1st, 2017
151
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. rednet.open("back")
  2.  
  3. local x, y = 1,4
  4. local x2, y2 = 1,6
  5. local x3, y3 = 1,8
  6. local x4, y4 = 1,10
  7. local x5, y5 = 1,12
  8. local x6, y6 = 1,14
  9. local choice1 = "[ ] Menu "
  10. local choice2 = "[ ] Remote "
  11. local choice3 = "[ ] Rename "
  12. local choice4 = "[ ] Refuel "
  13. local choice5 = "[ ] Restart "
  14. local choice6 = "[ ] Shutdown "
  15.  
  16. term.clear()
  17. term.setCursorPos(1, 1)
  18. term.setTextColor(colors.lightGray)
  19. print("--------------------------")
  20. print("---")
  21. term.setTextColor(colors.lightBlue)
  22. term.setCursorPos(4, 2)
  23. print("Bubble Bot Computers")
  24. term.setTextColor(colors.lightGray)
  25. term.setCursorPos(24, 2)
  26. print("---")
  27. print("--------------------------")
  28. local function drawMenu()
  29. sleep(.1)
  30. term.setCursorPos(x, y)
  31. term.setTextColor(colors.white)
  32. write(choice1)
  33. term.setCursorPos(x2, y2)
  34. write(choice2)
  35. term.setCursorPos(x3, y3)
  36. write(choice3)
  37. term.setCursorPos(x4, y4)
  38. write(choice4)
  39. term.setCursorPos(x5, y5)
  40. write(choice5)
  41. term.setCursorPos(x6, y6)
  42. write(choice6)
  43.  
  44. end
  45.  
  46. drawMenu()
  47.  
  48. while true do
  49. local event, button, cx, cy = os.pullEvent()
  50. if event == "mouse_click" then
  51. if cx >= x and cx < choice1:len() and cy == y and button == 1 then
  52. term.clear()
  53. term.setCursorPos(1, 1)
  54. term.setTextColor(colors.white)
  55. shell.run("menu")
  56. elseif cx >= x2 and cx < choice2:len() and cy == y2 and button == 1 then
  57. term.clear()
  58. term.setCursorPos(1, 1)
  59. term.setTextColor(colors.white)
  60. shell.run("remote")
  61. elseif cx >= x3 and cx < choice3:len() and cy == y3 and button == 1 then
  62. rednet.broadcast("TurtleName")
  63. sleep(1)
  64. term.clear()
  65. term.setCursorPos(1, 1)
  66. print("Name:")
  67. term.setCursorPos(6, 1)
  68. input = read()
  69. sleep(3)
  70. rednet.broadcast(input)
  71. sleep(2.5)
  72. shell.run("turtlemenu")
  73. elseif cx >= x4 and cx < choice3:len() and cy == y4 and button == 1 then
  74. rednet.broadcast("TS Refuel")
  75. sleep(.1)
  76. shell.run("turtlemenu")
  77. elseif cx >= x5 and cx < choice3:len() and cy == y5 and button == 1 then
  78. rednet.broadcast("TurtleRestart")
  79. elseif cx >= x6 and cx < choice3:len() and cy == y6 and button == 1 then
  80. rednet.broadcast("TurtleShutdown")
  81. sleep(1)
  82. shell.run("menu")
  83. end
  84. break
  85. end
  86. end
RAW Paste Data