Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bedrockDetected = false
- d=0
- n=0
- facingNorth=true
- e=0
- facingEast=false
- s=0
- facingSouth=false
- w=0
- facingWest=false
- stripNDone=false
- stripEDone=false
- stripSDone=false
- stripWDone=false
- chestDistanceFromHome=0
- itemsDelivered = true
- while bedrockDetected == false do
- --detecting bedrock
- local success, data = turtle.inspectDown()
- if data.name == "minecraft:bedrock" then
- bedrockDetected = true
- end
- --
- --checking fuel level and refueling with coal in inventory
- if turtle.getFuelLevel()<=50 then
- for i = 1, 16 do -- loop through the slots
- turtle.select(i) -- change to the slot
- if turtle.refuel(0) then -- if it's valid fuel
- local halfStack = math.ceil(turtle.getItemCount(i)/2) -- work out half of the amount of fuel in the slot
- turtle.refuel(halfStack) -- consume half the stack as fuel
- end
- end
- end
- if chestDistanceFromHome > 0 and d==0 and itemsDelivered == false then
- for i = 1, chestDistanceFromHome do
- turtle.up()
- end
- for i = 1, 16 do -- loop through the slots
- if turtle.refuel(0) == false then
- turtle.select(i) -- change to the slot
- turtle.drop()
- end
- end
- itemsDelivered=true
- end
- if chestDistanceFromHome > 0 and d==0 and itemsDelivered == true then
- for i = 1, chestDistanceFromHome do
- turtle.down()
- end
- itemsDelivered=false
- end
- --
- --digging down and keeping count of depth
- if turtle.detectDown() and d<2 then
- turtle.digDown()
- print("block detected, digging down")
- print("current distance to next strip =", 2-d)
- end
- --moving down and keeping count of depth
- if turtle.detectDown() == false and d<2 then
- chestDistanceFromHome=chestDistanceFromHome+1
- d=d+1
- turtle.down()
- print("block not detected, moving down")
- print("current distance to next strip =", 2-d)
- end
- --
- --mining forward
- if turtle.detect() and d==2 and facingNorth ==true and stripNDone==false then
- turtle.dig()
- print("mining forward")
- print("current distance to next strip =", 50-n)
- end
- --moving forward and keeping count of depth
- if turtle.detect() == false and d==2 and facingNorth == true and stripNDone==false then
- turtle.forward()
- n=n+1
- if n==50 then
- stripNDone=true
- end
- end
- --
- --going home after finishing strip
- if facingNorth==true and n>=0 and stripNDone == true then
- turtle.back()
- n=n-1
- if n==0 then
- facingNorth=false
- facingEast=true
- turtle.turnRight()
- end
- end
- --
- --mining east
- if turtle.detect() and d==2 and facingEast == true and stripEDone==false then
- turtle.dig()
- print("mining east")
- print("current distance to next strip =", 50-e)
- end
- --moving east and keeping count of depth
- if turtle.detect() == false and d==2 and facingEast == true and stripEDone==false then
- turtle.forward()
- e=e+1
- if e==50 then
- stripEDone=true
- end
- end
- --
- --going home after finishing strip
- if facingEast==true and e>=0 and stripEDone == true then
- turtle.back()
- e=e-1
- if e==0 then
- facingEast=false
- facingSouth=true
- turtle.turnRight()
- end
- end
- --
- --mining south
- if turtle.detect() and d==2 and facingSouth == true and stripSDone==false then
- turtle.dig()
- print("mining south")
- print("current distance to next strip =", 50-s)
- end
- --moving east and keeping count of depth
- if turtle.detect() == false and d==2 and facingSouth == true and stripSDone==false then
- turtle.forward()
- s=s+1
- if s==50 then
- stripSDone=true
- end
- end
- --
- --going home after finishing strip
- if facingSouth==true and e>=0 and stripSDone == true then
- turtle.back()
- s=s-1
- if s==0 then
- facingSouth=false
- facingWest=true
- turtle.turnRight()
- end
- end
- --
- --mining West
- if turtle.detect() and d==2 and facingWest == true and stripWDone==false then
- turtle.dig()
- print("mining west")
- print("current distance to next strip =", 50-s)
- end
- --moving east and keeping count of depth
- if turtle.detect() == false and d==2 and facingWest == true and stripWDone==false then
- turtle.forward()
- w=w+1
- if w==50 then
- stripWDone=true
- end
- end
- --
- --going home after finishing strip
- if facingWest==true and e>=0 and stripWDone == true then
- turtle.back()
- w=w-1
- if w==0 then
- facingWest=false
- facingNorth=true
- turtle.turnRight()
- d=0
- stripNDone=false
- stripEDone=false
- stripSDone=false
- stripWDone=false
- itemsDelivered=false
- end
- end
- --
- end
Add Comment
Please, Sign In to add comment