Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Digs a 10x10x3 room.
- -- Meant for quick excavation, not mass harvesting.
- -- Use odd numbers for it to return to its starting point
- roomSize = 9
- -- Tracks the turtle's position
- turtlePos = vector.new(0,0,0)
- while turtlePos.y < roomSize do
- -- Dig x column away from baseline
- while turtlePos.x < roomSize do
- while turtle.detect() do
- turtle.dig()
- end
- -- Dig forward
- while not turtle.forward() do
- os.sleep(1)
- end
- turtlePos.x = turtlePos.x + 1
- turtle.digUp()
- turtle.digDown()
- end
- -- Move to the right 1 Y column.
- turtle.turnRight()
- while turtle.detect() do
- turtle.dig()
- end
- -- Move to the right 1
- while not turtle.forward() do
- os.sleep(1)
- end
- turtlePos.y = turtlePos.y + 1
- turtle.digUp()
- turtle.digDown()
- -- Turn again to continue digging.
- turtle.turnRight()
- -- Dig x column back to baseline
- while turtlePos.x > 1 do
- while turtle.detect() do
- turtle.dig()
- end
- -- Dig forward
- while not turtle.forward() do
- os.sleep(1)
- end
- turtlePos.x = turtlePos.x - 1
- turtle.digUp()
- turtle.digDown()
- end
- if turtlePos.y < roomSize then
- -- Move to the right 1 if we haven't finished the dig.
- turtle.turnLeft()
- while turtle.detect() do
- turtle.dig()
- end
- while not turtle.forward() do
- os.sleep(1)
- end
- turtlePos.y = turtlePos.y + 1
- turtle.digUp()
- turtle.digDown()
- turtle.turnLeft()
- end
- end
- -- Return home
- turtle.turnRight()
- while turtlePos.y > 0 do
- while turtle.detect() do
- turtle.dig()
- end
- -- Dig forward
- while not turtle.forward() do
- os.sleep(1)
- end
- turtlePos.y = turtlePos.y - 1
- end
- turtle.turnRight()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement