Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function DigHorizontalPlane(width, depth, turnRightFirst, alreadyInPlane)
- rowCount = 1
- nextTurn = 0
- if turnRightFirst then
- nextTurn = 1 -- Positive indicates a right turn
- else
- nextTurn = -1 -- Negative indicates a left turn
- end
- -- If you aren't already in the plane, go forward one block to enter
- if not alreadyInPlane then
- print("Digging into plane...")
- DigStraightAhead(1)
- print("Done digging into plane")
- end
- while (rowCount <= width) do
- print("PlaneCount: ", rowCount)
- DigStraightAhead(depth-1)
- -- We only need to execute the turn if you're not on the last set
- if rowCount < width then
- -- Code for turning right
- if nextTurn > 0 then
- turtle.turnRight()
- while true do -- Ensure that the turtle moves
- turtle.dig()
- res = turtle.forward()
- if res then
- break
- end
- end
- turtle.turnRight()
- -- Code for turning left
- else
- turtle.turnLeft()
- while true do -- Ensure that the turtle moves
- turtle.dig()
- res = turtle.forward()
- if res then
- break
- end
- end
- turtle.turnLeft()
- end
- -- Invert the turn so the next one goes the other way
- end
- nextTurn = nextTurn * -1
- rowCount = rowCount + 1
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement