Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- turtle_location = vector.new(0, 0, 0)
- area_size = vector.new(0, 0, 0)
- -- Gets user input
- function get_size()
- print("How long?")
- area_size.x = tonumber(read())
- print("How wide?")
- area_size.y = tonumber(read())
- print("How tall?")
- area_size.z = tonumber(read())
- end
- -- Move the turtle 1 to the right
- function move_right()
- turtle.turnRight()
- while turtle.detect() do
- turtle.dig()
- end
- while not turtle.forward() do os.sleep(5) end
- turtle.turnLeft()
- turtle_location.y = turtle_location.y + 1
- end
- -- Clears up to Z height.
- function clear_up()
- repeat
- while turtle.detectUp() do
- turtle.digUp()
- end
- while not turtle.up() do os.sleep(5) end
- turtle_location.z = turtle_location.z + 1
- until turtle_location.z >= area_size.z-1
- repeat
- while not turtle.down() do os.sleep(5) end
- turtle_location.z = turtle_location.z - 1
- until turtle_location.z == 0
- end
- -- Dig straight up, then return to base height.
- -- Move forward 1. Repeat dig up procedure.
- -- Clears a row up to Z height.
- function x_clear()
- print("starting x_clear")
- clear_up()
- while turtle_location.x < area_size.x-1 do
- while turtle.detect() do
- turtle.dig()
- end
- while not turtle.forward() do os.sleep(5) end
- clear_up()
- turtle_location.x = turtle_location.x + 1
- end
- repeat
- while not turtle.back() do os.sleep(5) end
- turtle_location.x = turtle_location.x - 1
- until turtle_location.x == 0
- end
- function area_clear()
- x_clear()
- while turtle_location.y < (area_size.y-1) and area_size.y ~= 1 do
- move_right()
- x_clear()
- end
- turtle.turnLeft()
- repeat
- while not turtle.forward() do os.sleep(5) end
- turtle_location.y = turtle_location.y - 1
- until turtle_location.y == 0
- turtle.turnRight()
- end
- get_size()
- area_clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement