Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local uInput = ("")
- local parameters = {}
- term.setBackgroundColor(colors.gray)
- shell.run("CadeOS/headerCadeOS.lua")
- -- Opening message
- function openingMessage()
- term.setTextColor(colors.orange)
- print("Choose a program to run:")
- end
- -- Main Menu
- function mainMenu()
- print()
- term.setTextColor(colors.orange)
- term.write("1. ")
- term.setTextColor(colors.red)
- term.write("Movement")
- print()
- term.setTextColor(colors.orange)
- term.write("2. ")
- term.setTextColor(colors.red)
- term.write("Rotate")
- print()
- term.setTextColor(colors.orange)
- term.write("3. ")
- term.setTextColor(colors.red)
- term.write("Mine (Manual Setup)")
- print()
- term.setTextColor(colors.orange)
- term.write("4. ")
- term.setTextColor(colors.red)
- term.write("Mine (Auto Setup)")
- end
- -- Main Menu User Input
- function userInput()
- print()
- print()
- term.setTextColor(colors.green)
- uInput = io.read()
- end
- -- get user input for parameters
- function manualMineMenu()
- print("Quarry length: ")
- parameters[1] = io.read()
- print("Quarry width: ")
- parameters[2] = io.read()
- print("Turtle Y: ")
- parameters[3] = io.read()
- local listtype = 12
- while(listtype ~= 1 and listtype ~= 0) do
- print("Whitelist y/n?")
- listtype = io.read()
- if(listtype == "yes" or listtype == "Yes" or listtype == "y" or listtype == "Y") then
- listtype = 1
- elseif(listtype == "no" or listtype == "No" or listtype == "n" or listtype == "N") then
- listtype = 0
- else
- print("Invalid answer, please type either yes or no")
- end
- end
- parameters[4] = listtype
- print("Do you want to dig the whole chunk, y/n?")
- local dummy = io.read()
- if dummy == "n" or dummy == "N" or dummy == "no" or dummy == "No" then
- print("Layers to dig?")
- parameters[5] = io.read()
- else
- parameters[5] = parameters[3]
- end
- end
- --------------------------------------
- -- Movement Menu
- function movementMenu()
- print()
- term.setTextColor(colors.orange)
- term.write("1. ")
- term.setTextColor(colors.red)
- term.write("Forward (32 blocks)")
- print()
- term.setTextColor(colors.orange)
- term.write("2. ")
- term.setTextColor(colors.red)
- term.write("Backward (32 blocks)")
- print()
- term.setTextColor(colors.orange)
- term.write("3. ")
- term.setTextColor(colors.red)
- term.write("Right (6 blocks)")
- print()
- term.setTextColor(colors.orange)
- term.write("4. ")
- term.setTextColor(colors.red)
- term.write("Left (6 blocks)")
- end
- -- Rotate Menu
- function rotateMenu()
- print()
- term.setTextColor(colors.orange)
- term.write("1. ")
- term.setTextColor(colors.red)
- term.write("Right")
- print()
- term.setTextColor(colors.orange)
- term.write("2. ")
- term.setTextColor(colors.red)
- term.write("Left")
- print()
- term.setTextColor(colors.orange)
- term.write("3. ")
- term.setTextColor(colors.red)
- term.write("Behind")
- end
- -- Invalid Response
- function invalidResponse()
- print()
- term.setTextColor(colors.green)
- term.write(uInput)
- term.setTextColor(colors.orange)
- term.write(" is not a valid command")
- print()
- print()
- end
- -- Command Sent
- function commandSent()
- term.setTextColor(colors.orange)
- term.write("Command Sent: ")
- term.setTextColor(colors.green)
- end
- -- Main Menu User Input Responses
- function uInputMainMenuResponse()
- if (uInput == "1") or (uInput == "move") or (uInput == "movement") or (uInput == "Movement") then
- movementMenu()
- uInput = ("")
- userInput()
- uInputMovementMenuResponse()
- shell.run("CadeOS/remote.lua")
- elseif (uInput == "2") or (uInput == "rotate") or (uInput == "Rotate") then
- rotateMenu()
- uInput = ("")
- userInput()
- uInputRotateMenuResponse()
- shell.run("CadeOS/remote.lua")
- elseif (uInput == "3") or (uInput == "Mine")then
- manualMineMenu()
- print()
- for i=1,5 do
- print(parameters[i])
- rednet.broadcast("cadeMine",parameters["i"])
- end
- --rednet.broadcast("cadeMine")
- --commandSent()
- --term.write("Manual Mine")
- --shell.run("CadeOS/remote.lua")
- elseif (uInput == "4") or (uInput == "Mine Auto") then
- rednet.broadcast("cadeMine2")
- commandSent()
- term.write("Auto Mine")
- elseif (uInput == "exit") then
- print("emergency stop")
- else
- invalidResponse()
- sleep(2)
- shell.run("CadeOS/remote.lua")
- end
- uInput = ""
- end
- -- Movement Menu User Input Responses
- function uInputMovementMenuResponse()
- print()
- if (uInput == "1") or (uInput == "move") or (uInput == "movement") or (uInput == "Movement") then
- rednet.broadcast("movement", "moveForward")
- commandSent()
- term.write("Move Forward")
- elseif (uInput == "2") or (uInput == "back") or (uInput == "Back") or (uInput == "backward") or (uInput == "Backward") then
- rednet.broadcast("movement", "moveBackward")
- commandSent()
- term.write("Move Backward")
- elseif (uInput == "3") or (uInput == "right") or (uInput == "Right") then
- rednet.broadcast("movement", "moveRight")
- commandSent()
- term.write("Move Right")
- elseif (uInput == "4") or (uInput == "left") or (uInput == "Left") then
- rednet.broadcast("movement", "moveLeft")
- commandSent()
- term.write("Move Left")
- elseif (uInput == "exit") then
- print("emergency stop")
- else
- invalidResponse()
- sleep(2)
- shell.run("CadeOS/remote.lua")
- end
- end
- -- Rotate Menu User Input Response
- function uInputRotateMenuResponse()
- print()
- if (uInput == "1") or (uInput == "right") or (uInput == "Right") then
- rednet.broadcast("rotate", "right")
- commandSent()
- term.write("Rotate Right")
- elseif (uInput == "2") or (uInput == "left") or (uInput == "Left") then
- rednet.broadcast("rotate", "left")
- commandSent()
- term.write("Rotate Left")
- elseif (uInput == "3") or (uInput == "Behind") or (uInput == "behind") or (uInput == "180") then
- rednet.broadcast("rotate", "behind")
- commandSent()
- term.write("Rotate Behind")
- elseif (uInput == "exit") then
- print("emergency stop")
- else
- invalidResponse()
- sleep(2)
- shell.run("CadeOS/remote.lua")
- end
- end
- -- Main Program
- openingMessage()
- mainMenu()
- userInput()
- uInputMainMenuResponse()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement