Advertisement
Cadevine

remote

Jan 17th, 2025 (edited)
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.74 KB | None | 0 0
  1. local uInput = ("")
  2. local parameters = {}
  3. term.setBackgroundColor(colors.gray)
  4.  
  5. shell.run("CadeOS/headerCadeOS.lua")
  6. -- Opening message
  7. function openingMessage()
  8. term.setTextColor(colors.orange)
  9. print("Choose a program to run:")
  10. end
  11.  
  12. -- Main Menu
  13. function mainMenu()
  14. print()
  15. term.setTextColor(colors.orange)
  16. term.write("1. ")
  17. term.setTextColor(colors.red)
  18. term.write("Movement")
  19.  
  20. print()
  21. term.setTextColor(colors.orange)
  22. term.write("2. ")
  23. term.setTextColor(colors.red)
  24. term.write("Rotate")
  25.  
  26. print()
  27. term.setTextColor(colors.orange)
  28. term.write("3. ")
  29. term.setTextColor(colors.red)
  30. term.write("Mine (Manual Setup)")
  31.  
  32. print()
  33. term.setTextColor(colors.orange)
  34. term.write("4. ")
  35. term.setTextColor(colors.red)
  36. term.write("Mine (Auto Setup)")
  37. end
  38.  
  39. -- Main Menu User Input
  40. function userInput()
  41. print()
  42. print()
  43. term.setTextColor(colors.green)
  44. uInput = io.read()
  45. end
  46.  
  47. -- get user input for parameters
  48. function manualMineMenu()
  49. print("Quarry length: ")
  50. parameters[1] = io.read()
  51. print("Quarry width: ")
  52. parameters[2] = io.read()
  53. print("Turtle Y: ")
  54. parameters[3] = io.read()
  55.  
  56. local listtype = 12
  57. while(listtype ~= 1 and listtype ~= 0) do
  58. print("Whitelist y/n?")
  59. listtype = io.read()
  60. if(listtype == "yes" or listtype == "Yes" or listtype == "y" or listtype == "Y") then
  61. listtype = 1
  62. elseif(listtype == "no" or listtype == "No" or listtype == "n" or listtype == "N") then
  63. listtype = 0
  64. else
  65. print("Invalid answer, please type either yes or no")
  66. end
  67. end
  68. parameters[4] = listtype
  69.  
  70. print("Do you want to dig the whole chunk, y/n?")
  71. local dummy = io.read()
  72. if dummy == "n" or dummy == "N" or dummy == "no" or dummy == "No" then
  73. print("Layers to dig?")
  74. parameters[5] = io.read()
  75. else
  76. parameters[5] = parameters[3]
  77. end
  78. end
  79. --------------------------------------
  80.  
  81. -- Movement Menu
  82. function movementMenu()
  83. print()
  84. term.setTextColor(colors.orange)
  85. term.write("1. ")
  86. term.setTextColor(colors.red)
  87. term.write("Forward (32 blocks)")
  88.  
  89. print()
  90. term.setTextColor(colors.orange)
  91. term.write("2. ")
  92. term.setTextColor(colors.red)
  93. term.write("Backward (32 blocks)")
  94.  
  95. print()
  96. term.setTextColor(colors.orange)
  97. term.write("3. ")
  98. term.setTextColor(colors.red)
  99. term.write("Right (6 blocks)")
  100.  
  101. print()
  102. term.setTextColor(colors.orange)
  103. term.write("4. ")
  104. term.setTextColor(colors.red)
  105. term.write("Left (6 blocks)")
  106. end
  107.  
  108. -- Rotate Menu
  109. function rotateMenu()
  110. print()
  111. term.setTextColor(colors.orange)
  112. term.write("1. ")
  113. term.setTextColor(colors.red)
  114. term.write("Right")
  115.  
  116. print()
  117. term.setTextColor(colors.orange)
  118. term.write("2. ")
  119. term.setTextColor(colors.red)
  120. term.write("Left")
  121.  
  122. print()
  123. term.setTextColor(colors.orange)
  124. term.write("3. ")
  125. term.setTextColor(colors.red)
  126. term.write("Behind")
  127. end
  128.  
  129. -- Invalid Response
  130. function invalidResponse()
  131. print()
  132. term.setTextColor(colors.green)
  133. term.write(uInput)
  134. term.setTextColor(colors.orange)
  135. term.write(" is not a valid command")
  136. print()
  137. print()
  138. end
  139.  
  140. -- Command Sent
  141. function commandSent()
  142. term.setTextColor(colors.orange)
  143. term.write("Command Sent: ")
  144. term.setTextColor(colors.green)
  145. end
  146.  
  147. -- Main Menu User Input Responses
  148. function uInputMainMenuResponse()
  149. if (uInput == "1") or (uInput == "move") or (uInput == "movement") or (uInput == "Movement") then
  150. movementMenu()
  151. uInput = ("")
  152. userInput()
  153. uInputMovementMenuResponse()
  154. shell.run("CadeOS/remote.lua")
  155. elseif (uInput == "2") or (uInput == "rotate") or (uInput == "Rotate") then
  156. rotateMenu()
  157. uInput = ("")
  158. userInput()
  159. uInputRotateMenuResponse()
  160. shell.run("CadeOS/remote.lua")
  161. elseif (uInput == "3") or (uInput == "Mine")then
  162. manualMineMenu()
  163. print()
  164. for i=1,5 do
  165. print(parameters[i])
  166. rednet.broadcast("cadeMine",parameters["i"])
  167. end
  168. --rednet.broadcast("cadeMine")
  169. --commandSent()
  170. --term.write("Manual Mine")
  171. --shell.run("CadeOS/remote.lua")
  172. elseif (uInput == "4") or (uInput == "Mine Auto") then
  173. rednet.broadcast("cadeMine2")
  174. commandSent()
  175. term.write("Auto Mine")
  176. elseif (uInput == "exit") then
  177. print("emergency stop")
  178. else
  179. invalidResponse()
  180. sleep(2)
  181. shell.run("CadeOS/remote.lua")
  182. end
  183. uInput = ""
  184. end
  185.  
  186. -- Movement Menu User Input Responses
  187. function uInputMovementMenuResponse()
  188. print()
  189. if (uInput == "1") or (uInput == "move") or (uInput == "movement") or (uInput == "Movement") then
  190. rednet.broadcast("movement", "moveForward")
  191. commandSent()
  192. term.write("Move Forward")
  193. elseif (uInput == "2") or (uInput == "back") or (uInput == "Back") or (uInput == "backward") or (uInput == "Backward") then
  194. rednet.broadcast("movement", "moveBackward")
  195. commandSent()
  196. term.write("Move Backward")
  197. elseif (uInput == "3") or (uInput == "right") or (uInput == "Right") then
  198. rednet.broadcast("movement", "moveRight")
  199. commandSent()
  200. term.write("Move Right")
  201. elseif (uInput == "4") or (uInput == "left") or (uInput == "Left") then
  202. rednet.broadcast("movement", "moveLeft")
  203. commandSent()
  204. term.write("Move Left")
  205. elseif (uInput == "exit") then
  206. print("emergency stop")
  207. else
  208. invalidResponse()
  209. sleep(2)
  210. shell.run("CadeOS/remote.lua")
  211. end
  212. end
  213.  
  214. -- Rotate Menu User Input Response
  215. function uInputRotateMenuResponse()
  216. print()
  217. if (uInput == "1") or (uInput == "right") or (uInput == "Right") then
  218. rednet.broadcast("rotate", "right")
  219. commandSent()
  220. term.write("Rotate Right")
  221. elseif (uInput == "2") or (uInput == "left") or (uInput == "Left") then
  222. rednet.broadcast("rotate", "left")
  223. commandSent()
  224. term.write("Rotate Left")
  225. elseif (uInput == "3") or (uInput == "Behind") or (uInput == "behind") or (uInput == "180") then
  226. rednet.broadcast("rotate", "behind")
  227. commandSent()
  228. term.write("Rotate Behind")
  229. elseif (uInput == "exit") then
  230. print("emergency stop")
  231. else
  232. invalidResponse()
  233. sleep(2)
  234. shell.run("CadeOS/remote.lua")
  235. end
  236. end
  237.  
  238. -- Main Program
  239. openingMessage()
  240. mainMenu()
  241. userInput()
  242. uInputMainMenuResponse()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement