Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function directionDetection(rows, cols)
- local turnRight = false
- local trenchlessMode = false
- io.write ("Is the turtle on the right or on the left of the field? (r/l)\n")
- local direction = io.read()
- if direction == "r" or direction == "R" then
- turtle.turnRight()
- if turtle.forward() then
- if not turtle.detect() then
- io.write("The Turtle detected no wall around the designated trench. This may mean decreased effeciency or that you've inputted the wrong side. \nProceed? (Y/n)\n")
- local check = io.read()
- if check == "Y" or check == "y" then
- turtle.back()
- turtle.turnLeft()
- elseif check == "N" or check == "n" then
- turtle.back()
- turtle.turnLeft()
- return directionDetection(rows, cols)
- else
- io.write("Incorrect input. Restarting.\n")
- turtle.back()
- turtle.turnLeft()
- return directionDetection(rows, cols)
- end
- else
- io.write("Trench detected. Continuing.\n")
- turtle.back()
- turtle.turnLeft()
- end
- else
- io.write("The Turtle detected a lack of a trench around the bamboo farm. Do you want to activate Trenchless Mode? (Y/n)\n")
- turtle.turnLeft()
- local check = io.read()
- if check == "y" or check == "Y" then
- trenchlessMode = true
- elseif check == "n" or check == "N" then
- return directionDetection(rows, cols)
- else
- io.write("Incorrect input. Restarting.\n")
- return directionDetection(rows, cols)
- end
- end
- turnRight = false
- elseif direction == "l" or direction == "L" then
- turtle.turnLeft()
- if turtle.forward() then
- if not turtle.detect() then
- io.write("The Turtle detected no wall around the designated trench. This may mean decreased effeciency or that you've inputted the wrong side. \nProceed? (Y/n)\n")
- local check = io.read()
- if check == "Y" or check == "y" then
- turtle.back()
- turtle.turnRight()
- elseif check == "N" or check == "n" then
- turtle.back()
- turtle.turnRight()
- return directionDetection(rows, cols)
- else
- io.write("Incorrect input. Restarting.\n")
- turtle.back()
- turtle.turnRight()
- return directionDetection(rows, cols)
- end
- else
- io.write("Trench detected. Continuing.\n")
- turtle.back()
- turtle.turnRight()
- end
- else
- io.write("The Turtle detected a lack of a trench around the bamboo farm. Do you want to activate Trenchless Mode? (Y/n)\n")
- turtle.turnRight()
- local check = io.read()
- if check == "y" or check == "Y" then
- trenchlessMode = true
- elseif check == "n" or check == "N" then
- return directionDetection(rows, cols)
- else
- io.write("Incorrect input. Restarting.\n")
- return directionDetection(rows, cols)
- end
- end
- turnRight = true
- else
- io.write("Incorrect input. Restarting.\n")
- return directionDetection(rows, cols)
- end
- checkFuelLevel(rows, cols)
- return turnRight, trenchlessMode
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement