Advertisement
Cadevine

_remote.lua

Jan 20th, 2025 (edited)
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.11 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. -- User Input for cadeMine Program
  48. function manualMineMenu()
  49.     print()
  50.     term.setTextColor(colors.orange)
  51.     print("Quarry length: ")
  52.     term.setTextColor(colors.green)
  53.     parameters[1] = io.read()
  54.     print()
  55.     term.setTextColor(colors.orange)
  56.     print("Quarry width: ")
  57.     term.setTextColor(colors.green)
  58.     parameters[2] = io.read()
  59.     print()
  60.     term.setTextColor(colors.orange)
  61.     print("Quarry height: ")
  62.     term.setTextColor(colors.green)
  63.     parameters[3] = io.read()
  64. end
  65.  
  66. -- Movement Menu
  67. function movementMenu()
  68.     print()
  69.     term.setTextColor(colors.orange)
  70.     term.write("1. ")
  71.     term.setTextColor(colors.red)
  72.     term.write("Forward (32 blocks)")
  73.    
  74.     print()
  75.     term.setTextColor(colors.orange)
  76.     term.write("2. ")
  77.     term.setTextColor(colors.red)
  78.     term.write("Backward (32 blocks)")
  79.  
  80.     print()
  81.     term.setTextColor(colors.orange)
  82.     term.write("3. ")
  83.     term.setTextColor(colors.red)
  84.     term.write("Right (6 blocks)")
  85.  
  86.     print()
  87.     term.setTextColor(colors.orange)
  88.     term.write("4. ")
  89.     term.setTextColor(colors.red)
  90.     term.write("Left (6 blocks)")
  91. end
  92.  
  93. -- Rotate Menu
  94. function rotateMenu()
  95.     print()
  96.     term.setTextColor(colors.orange)
  97.     term.write("1. ")
  98.     term.setTextColor(colors.red)
  99.     term.write("Right")
  100.    
  101.     print()
  102.     term.setTextColor(colors.orange)
  103.     term.write("2. ")
  104.     term.setTextColor(colors.red)
  105.     term.write("Left")
  106.  
  107.     print()
  108.     term.setTextColor(colors.orange)
  109.     term.write("3. ")
  110.     term.setTextColor(colors.red)
  111.     term.write("Behind")
  112. end
  113.  
  114. -- Invalid Response
  115. function invalidResponse()
  116.         print()
  117.         term.setTextColor(colors.green)
  118.         term.write(uInput)
  119.         term.setTextColor(colors.orange)
  120.         term.write(" is not a valid command")
  121.         print()
  122.         print()
  123. end
  124.  
  125. -- Command Sent
  126. function commandSent()
  127.         term.setTextColor(colors.orange)
  128.         term.write("Command Sent: ")
  129.         term.setTextColor(colors.green)
  130. end
  131.  
  132. -- Main Menu User Input Responses
  133. function uInputMainMenuResponse()
  134.     if (uInput == "1") or (uInput == "move") or (uInput == "movement") or (uInput == "Movement") then
  135.         movementMenu()
  136.         uInput = ("")
  137.         userInput()
  138.         uInputMovementMenuResponse()
  139.         shell.run("CadeOS/remote.lua")
  140.     elseif (uInput == "2") or (uInput == "rotate") or (uInput == "Rotate") then
  141.         rotateMenu()
  142.         uInput = ("")
  143.         userInput()
  144.         uInputRotateMenuResponse()
  145.         shell.run("CadeOS/remote.lua")
  146.     elseif (uInput == "3") or (uInput == "Mine")then
  147.         manualMineMenu()
  148.         print()
  149.         rednet.broadcast("cadeMine")
  150.         rednet.broadcast(parameters[1])
  151.         rednet.broadcast(parameters[2])
  152.         rednet.broadcast(parameters[3])
  153.         shell.run("CadeOS/remote.lua")
  154.                
  155.     elseif (uInput == "4") or (uInput == "Mine Auto") then
  156.         rednet.broadcast("cadeMine2")
  157.         commandSent()
  158.         term.write("Auto Mine")
  159.     elseif (uInput == "exit") then
  160.         print("emergency stop")
  161.     else
  162.         invalidResponse()
  163.         sleep(2)
  164.         shell.run("CadeOS/remote.lua")
  165.     end
  166.     uInput = ""
  167. end
  168.  
  169. -- Movement Menu User Input Responses
  170. function uInputMovementMenuResponse()
  171.     print()
  172.     if (uInput == "1") or (uInput == "move") or (uInput == "movement") or (uInput == "Movement") then
  173.         rednet.broadcast("movement", "moveForward")
  174.         commandSent()
  175.         term.write("Move Forward")
  176.     elseif (uInput == "2") or (uInput == "back")  or (uInput == "Back") or (uInput == "backward") or (uInput == "Backward") then
  177.         rednet.broadcast("movement", "moveBackward")
  178.         commandSent()
  179.         term.write("Move Backward")
  180.     elseif (uInput == "3") or (uInput == "right") or (uInput == "Right") then
  181.         rednet.broadcast("movement", "moveRight")
  182.         commandSent()
  183.         term.write("Move Right")
  184.     elseif (uInput == "4") or (uInput == "left")  or (uInput == "Left") then
  185.         rednet.broadcast("movement", "moveLeft")
  186.         commandSent()
  187.         term.write("Move Left")
  188.     elseif (uInput == "exit") then
  189.         print("emergency stop")
  190.     else
  191.         invalidResponse()
  192.         sleep(2)
  193.         shell.run("CadeOS/remote.lua")
  194.     end
  195. end
  196.  
  197. -- Rotate Menu User Input Response
  198. function uInputRotateMenuResponse()
  199.     print()
  200.     if (uInput == "1") or (uInput == "right") or (uInput == "Right") then
  201.         rednet.broadcast("rotate", "right")
  202.         commandSent()
  203.         term.write("Rotate Right")
  204.     elseif (uInput == "2") or (uInput == "left")  or (uInput == "Left") then
  205.         rednet.broadcast("rotate", "left")
  206.         commandSent()
  207.         term.write("Rotate Left")
  208.     elseif (uInput == "3") or (uInput == "Behind") or (uInput == "behind") or (uInput == "180") then
  209.         rednet.broadcast("rotate", "behind")
  210.         commandSent()
  211.         term.write("Rotate Behind")
  212.     elseif (uInput == "exit") then
  213.         print("emergency stop")
  214.     else
  215.         invalidResponse()
  216.         sleep(2)
  217.         shell.run("CadeOS/remote.lua")
  218.     end
  219. end
  220.  
  221. -- Main Program
  222. openingMessage()
  223. mainMenu()
  224. userInput()
  225. uInputMainMenuResponse()
  226.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement