Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- VerticalDig = 3
- DistansDig = 80
- WidthDig = 10
- x = 0
- y = 0
- z = 0
- side = "+X"
- local function Refuel()
- if turtle.getFuelLevel() < 30 then
- turtle.select(1)
- turtle.refuel(1)
- end
- end
- local function UnLoad()
- for i = 2, 16, 1 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(1)
- end
- local function TrueBreack(route)
- Refuel()
- value = false
- if route == "Up" then
- value = turtle.detectUp()
- elseif route == "Forvard" then
- value = turtle.detect()
- elseif route == "Down" then
- value = turtle.detectDown()
- end
- while value do
- Refuel()
- if route == "Up" then
- turtle.digUp()
- value = turtle.detectUp()
- elseif route == "Forvard" then
- turtle.dig()
- value = turtle.detect()
- elseif route == "Down" then
- turtle.digDown()
- value = turtle.detectDown()
- end
- end
- end
- local function Rotate(localSide)
- if (string.sub(localSide,2,2) == string.sub(side,2,2)) and (not (string.sub(localSide,1,1) == string.sub(side,1,1))) then
- turtle.turnLeft()
- turtle.turnLeft()
- else
- if side == "+X" then
- if localSide == "+Z" then
- turtle.turnRight()
- elseif localSide == "-Z" then
- turtle.turnLeft()
- end
- elseif side == "-X" then
- if localSide == "+Z" then
- turtle.turnLeft()
- elsif localSide == "-Z" then
- turtle.turnRight()
- end
- elseif side == "+Z" then
- if localSide == "+X" then
- turtle.turnLeft()
- elseif localSide == "-X" then
- turtle.turnRight()
- end
- elseif side == "-Z" then
- if localSide == "+X" then
- turtle.turnRight()
- elseif localSide == "-X" then
- turtle.turnLeft()
- end
- end
- end
- end
- local function AnalogsMove(localSide,route)
- Rotate(localSide)
- TrueBreack(route)
- if route == "Up" then
- turtle.up()
- y = y + 1
- elseif route == "Forvard" then
- turtle.forward()
- if localSide == "+X" then
- x = x + 1
- elseif localSide == "-X" then
- x = x - 1
- elseif localSide == "+Z" then
- z = z + 1
- elseif localSide == "-Z" then
- z = z - 1
- end
- side = localSide
- elseif route == "Down" then
- y = y - 1
- turtle.down()
- end
- side = localSide
- end
- local function StepMove(localStep,cords)
- localSide = side
- route = "null"
- if not (cords == "y") then
- route = "Forvard"
- elseif localStep > 0 and cords == "y" then
- route = "Up"
- elseif localStep < 0 and cords == "y" then
- route = "Down"
- end
- if localStep > 0 and cords == "x" then
- localSide = "+X"
- elseif localStep < 0 and cords == "x" then
- localSide = "-X"
- elseif localStep < 0 and cords == "z" then
- localSide = "-Z"
- elseif localStep > 0 and cords == "z" then
- localSide = "+Z"
- end
- AnalogsMove(localSide,route)
- end
- local function MovePoint(localX,localY,localZ)
- while not (localY == y) do
- if localY > y then
- StepMove(1,"y")
- elseif localY < y then
- StepMove(-1,"y")
- end
- end
- while not (localZ == z) do
- if localZ > z then
- StepMove(1,"z")
- elseif localZ < z then
- StepMove(-1,"z")
- end
- end
- while not (localX == x) do
- if localX > x then
- StepMove(1,"x")
- elseif localX < x then
- StepMove(-1,"x")
- end
- end
- end
- local function CheckOverflow()
- turtle.select(16)
- localX = x
- localY = y
- localZ = z
- if turtle.getItemCount() >= 1 then
- turtle.select(1)
- MovePoint(0,0,0)
- Rotate("-X")
- UnLoad()
- MovePoint(localX,localY,localZ)
- end
- turtle.select(1)
- end
- local function DigArea()
- targetX = DistansDig
- targetZ = WidthDig
- stepX = 1
- stepZ = 1
- for h = 1, VerticalDig, 1 do
- while not (targetX == x) do
- while not (targetZ == z) do
- MovePoint(x,y,z+stepZ)
- TrueBreack("Up")
- TrueBreack("Down")
- CheckOverflow()
- end
- stepZ = stepZ * -1
- if stepZ == -1 then
- targetZ = 0
- else
- targetZ = WidthDig
- end
- MovePoint(x+stepX,y,z)
- TrueBreack("Up")
- TrueBreack("Down")
- end
- stepX = stepX * -1
- if stepX == -1 then
- targetX = 0
- else
- targetX = DistansDig
- end
- if h < VerticalDig then MovePoint(x,y+3,z) end
- end
- MovePoint(0,0,0)
- UnLoad()
- end
- DigArea()
Add Comment
Please, Sign In to add comment