Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Put bricks in slot 1, landmark in slot 2
- turtle_pos = vector.new(0, 0, 0)
- turtle_pos.x = 0
- turtle_pos.y = 0
- turtle_pos.z = 0
- square_size = vector.new(0, 0, 0)
- function place_corner()
- -- Move down 1 square.
- while not turtle.down() do
- turtle.digDown()
- os.sleep(1)
- end
- -- Decrement turtle's Z
- turtle_pos.z = turtle_pos.z - 1
- -- If no block is present, place block.
- if not turtle.detectDown() then
- turtle.select(1)
- turtle.placeDown()
- end
- -- Move up 1 level.
- while not turtle.up() do
- if turtle.detectUp() then turtle.digUp() end
- os.sleep(1)
- end
- -- Increment turtle's Z coordinate because it 1 block above where the quarry will be placed.
- turtle_pos.z = turtle_pos.z + 1
- -- Place landmark.
- turtle.select(2)
- turtle.placeDown()
- end
- -- Go through following code and convert to functions as needed.
- -- Get input
- -- Prompt for length and width.
- function mark_quarry()
- print("How long?")
- square_size.x = tonumber(read()) - 1
- print("How wide?")
- square_size.y = tonumber(read()) - 1
- -- Place bricks in slot 1, landmark in slot 2
- -- Turtle starts in lower left corner. Place block beneath turtle if no block there.
- if not turtle.detectDown() then
- turtle.select(1)
- turtle.placeDown()
- end
- while not turtle.up() do
- turtle.digUp()
- os.sleep(2)
- end
- -- Increment turtle's Z coordinate because it 1 block above where the quarry will be placed.
- turtle_pos.z = 1
- -- Place the lower left landmark.
- turtle.select(2)
- turtle.placeDown()
- -- Move to upper left corner:
- repeat
- while not turtle.forward() do
- if turtle.detect() then turtle.dig() end
- os.sleep(1)
- end
- turtle_pos.y = turtle_pos.y +1
- until turtle_pos.y >= square_size.y
- -- Place upper left landmark
- print("Placing upper left beacon")
- place_corner()
- -- Move to upper right.
- turtle.turnRight()
- repeat
- while not turtle.forward() do
- if turtle.detect() then turtle.dig() end
- os.sleep(1)
- end
- turtle_pos.x = turtle_pos.x + 1
- until turtle_pos.x >= square_size.x
- -- Place upper right
- print("Placing upper right beacon")
- place_corner()
- -- Move to lower right
- turtle.turnRight()
- repeat
- while not turtle.forward() do
- if turtle.detect() then turtle.dig() end
- os.sleep(1)
- end
- turtle_pos.y = turtle_pos.y - 1
- until turtle_pos.y <= 0
- -- Place lower right
- print("Place lower right beacon")
- place_corner()
- -- Return to just above point of origin.
- turtle.turnRight()
- repeat
- while not turtle.forward() do
- if turtle.detect() then turtle.dig() end
- os.sleep(1)
- end
- turtle_pos.x = turtle_pos.x - 1
- until turtle_pos.x <= 0
- end
- mark_quarry()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement