Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- if not #args == 3 then
- print("Usage: Args start x,y,z")
- return
- end
- local spiralSize = 4
- local bottom = -58
- local x, y, z = gps.locate(5)
- if not x then
- print("co-ord get failed")
- else
- print("start co-ord " .. x .. ", " .. y .. ", " .. z)
- end
- function returnStart()
- local facing = 0
- while not turtle.forward() do turtle.dig() end
- local a,b,c = gps.locate(5)
- if x-a == -1 then
- facing = 1
- elseif z-c == 1 then
- facing = 2
- elseif x-a == 1 then
- facing = 3
- else
- facing = 0
- end
- turtle.turnRight()
- turtle.turnRight()
- while not turtle.forward() do turtle.dig() end
- facing = (facing)%4
- print("facing = " .. facing)
- turtle.turnRight()
- turtle.turnRight()
- for i=0,facing do
- turtle.turnRight()
- end
- local xMove = x - args[1]
- local zMove = args[3] - z
- print(xMove)
- print(zMove)
- for i=0, xMove-1 do
- while not turtle.forward() do turtle.dig() end
- end
- turtle.turnLeft()
- for i=0, zMove-1 do
- while not turtle.forward() do turtle.dig() end
- end
- turtle.turnRight()
- turtle.turnRight()
- end
- function checkInv()
- isFull = true
- for i=1,15 do
- if turtle.getItemCount(i) == 0 then
- isFull = false
- end
- end
- if isFull == true then
- emptyInv()
- end
- end
- function emptyInv()
- turtle.select(16)
- while turtle.detectUp() do
- turtle.digUp()
- sleep(0.2)
- end
- turtle.up()
- while not turtle.placeDown() do turtle.digDown() end
- for i=1,15 do
- turtle.select(i)
- turtle.dropDown()
- end
- turtle.select(16)
- turtle.digDown()
- sleep(0.1)
- turtle.select(1)
- turtle.down()
- end
- function mineLayer()
- local spiralCount = spiralSize
- for i=1,spiralSize do
- for j=1,4 do
- for k=1,spiralCount do
- while not turtle.forward() do turtle.dig() end
- end
- turtle.turnRight()
- checkInv()
- end
- spiralCount = spiralCount - 2
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- end
- end
- returnStart()
- for l=bottom,args[2] do
- mineLayer()
- while turtle.detectDown() do
- turtle.digDown()
- end
- turtle.down()
- end
- emptyInv()
Advertisement
Add Comment
Please, Sign In to add comment