Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local realDepth = 0
- local rightTurn = true --If turning right will face the turtle in the right direction
- local oneHigh = false
- local xDistance = 0
- local yDistance = 0
- local zDistance = 0
- function initialColumn(depth) --Dig the initial column. Digs down either until it reaches depth, or it can't go down
- for i = 1,depth do
- turtle.digDown()
- if turtle.down() then
- realDepth = i
- zDistance = zDistance + 1
- else --If it cant go down, it adjusts what realDepth is (How deep the turtle can go)
- print("Hit the end! i:")
- print(i)
- realDepth = i - 1
- break
- end
- end
- for i = 1,realDepth do --Return to surface
- turtle.up()
- zDistance = zDistance - 1
- end
- end
- function turnaround()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function empty() --Empties inventory starting at slot 16
- turnaround()
- for i = 16,1,-1 do
- turtle.select(i)
- turtle.drop()
- end
- turnaround()
- end
- function digSlab(twoHigh, size)
- for x = 1,size do --Dimensions of the slab
- for y = 1,size do
- if (y == size) and not (x == size) then --When we hit the end
- if rightTurn then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- digBlock()
- turtle.forward()
- if rightTurn then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- rightTurn = not rightTurn --Change which direction to turn next time. This way the turtle will snake around
- else
- digBlock()
- turtle.forward() --Goes forward
- if twoHigh then --If we have to dig two high, also dig upwards
- digUp()
- end
- end
- end
- if x == size then
- print("Done slab! Now figure out returning to origin")
- --Returning to origin
- if not rightTurn then --Face the correct direction
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- --March on back
- for x = 1, size do
- turtle.forward()
- end
- if not rightTurn then --Face back towards the front
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
- end
- end
- function digBlock()
- local success,data = turtle.inspect()
- if (data.name == "minecraft:sand") or (data.name == "minecraft:gravel") then --If theres sand or gravel in front of the turtle
- while turtle.dig() do --Dig as long as you can
- end
- end
- turtle.dig() --Try to dig, even if nothing can fall in front of it
- end
- function digUp()
- turtle.digUp() --Dig at first
- local success,data = turtle.inspectUp()
- if (data.name == "minecraft:sand") or (data.name == "minecraft:gravel") then --If theres sand or gravel above the turtle now
- while turtle.digUp() do --Dig as long as you can
- end
- end
- end
- initialColumn(4)
- empty()
- turtle.down()
- digSlab(not oneHigh, 6)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement