Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- relative_x = 0
- relative_y = 0
- rotation = 0
- function rotateTo(targetRotation)
- while rotation % 4 ~= targetRotation do
- turtle.turnRight()
- rotation = rotation + 1
- end
- rotation = rotation % 4
- end
- function goTo(x, y)
- if x ~= relative_x then
- if x > relative_x then
- rotateTo(1)
- else
- rotateTo(3)
- end
- while x ~= relative_x do
- while true do
- local exists, _ = turtle.inspect()
- if exists then
- if not turtle.dig() then
- break
- end
- else
- break
- end
- end
- assert(turtle.forward())
- if x > relative_x then
- relative_x = relative_x + 1
- else
- relative_x = relative_x - 1
- end
- end
- end
- if y ~= relative_y then
- if y > relative_y then
- rotateTo(0)
- else
- rotateTo(2)
- end
- while y ~= relative_y do
- while true do
- local exists, _ = turtle.inspect()
- if exists then
- if not turtle.dig() then
- break
- end
- else
- break
- end
- end
- assert(turtle.forward())
- if y > relative_y then
- relative_y = relative_y + 1
- else
- relative_y = relative_y - 1
- end
- end
- end
- end
- for y = 0,20 do
- for x = 0,64 do
- if x % 2 == 0 then
- goTo(x, 0)
- goTo(x, 64)
- else
- goTo(x, 64)
- goTo(x, 0)
- end
- for slot = 1,16 do
- turtle.select(slot)
- detail = turtle.getItemDetail()
- if detail ~= nil then
- turtle.refuel(64)
- if not string.find(detail["name"], "ore") and not string.find(detail["name"], "raw") and not string.find(detail["name"], "diamond") and not string.find(detail["name"], "redstone") then
- turtle.drop(64)
- end
- end
- end
- end
- goTo(0, 0)
- rotateTo(2)
- for i = 1,y do
- turtle.up()
- end
- for slot = 1,16 do
- turtle.select(slot)
- turtle.drop(64)
- end
- for i = 1,y do
- turtle.down()
- end
- rotateTo(0)
- if y ~= -40 then
- turtle.digDown()
- assert(turtle.down())
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement