Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print "Turtle must be in down-left corner of a chunk not looking at a chunkwall on layer 1"
- print "Enderchest in slot 2 ,Fuel in slot 16 (optional, allows turtle to eat found fuel as a last resort)."
- while turtle.getItemCount(2) < 1 do
- print "Please put an ENDER CHEST in slot 1. Hit any key when done."
- os.pullEvent("char")
- end
- while turtle.getItemCount(1) < 2 do
- print "Please put three CHUNKLOADERS in slot 1. Hit any key when done."
- os.pullEvent("char")
- end
- local distance = 1
- local chunks = 2
- local chunkCounter = 0
- function GetFuelFromChest()
- turtle.select(2)
- DigHole()
- turtle.placeUp()
- turtle.select(16)
- turtle.dropUp()
- turtle.suckUp()
- turtle.select(2)
- turtle.digUp()
- turtle.suckUp()
- end
- function CheckFuel()
- if turtle.getFuelLevel() <= 20 then
- turtle.select(16)
- turtle.refuel(2)
- end
- if turtle.getFuelLevel() <= 1 then
- GetFuelFromChest()
- CheckFuel()
- end
- return true
- end
- function MoveForward()
- CheckFuel()
- if(turtle.forward()) then
- return true
- else
- return false
- end
- end
- function TurnLeft()
- turtle.turnLeft()
- end
- function TurnRight()
- turtle.turnRight()
- end
- function MoveUp()
- CheckFuel()
- if(turtle.up()) then
- return true
- end
- return false
- end
- function MoveDown()
- CheckFuel()
- if(turtle.down()) then
- return true
- end
- return false
- end
- function Dig()
- while(turtle.detect()) do
- turtle.dig()
- turtle.suck()
- end
- end
- function DigHole()
- while(turtle.detectUp()) do
- turtle.digUp()
- turtle.suckUp()
- end
- end
- function DigUp()
- for y = 1, 13 do
- while(MoveUp() == false) do
- turtle.digUp()
- turtle.suckUp()
- end
- end
- end
- function DigDown()
- for y = 1, 13 do
- while(MoveDown() == false) do
- turtle.digDown()
- turtle.suckDown()
- end
- end
- end
- function DigForward()
- while(MoveForward() == false) do
- turtle.dig()
- turtle.suck()
- end
- end
- function DumpInventory()
- while turtle.detectUp() do
- turtle.digUp()
- end
- turtle.select(2)
- while turtle.placeUp() == false do
- turtle.digUp()
- end
- local iLastInventorySlot = 16
- if(turtle.getItemCount(16) > 0) then
- iLastInventorySlot = 15
- end
- for i = 3, iLastInventorySlot do
- turtle.select(i)
- turtle.dropUp()
- end
- turtle.select(2)
- turtle.digUp()
- end
- function PlaceChunkUp()
- turtle.select(1)
- while turtle.placeUp() == false do
- turtle.digUp()
- end
- end
- function PlaceChunkFront()
- turtle.select(1)
- while turtle.place() == false do
- turtle.dig()
- end
- end
- function PlaceChunkBack()
- turtle.select(1)
- TurnRight()
- TurnRight()
- while turtle.place() == false do
- turtle.dig()
- end
- TurnRight()
- TurnRight()
- end
- function PlaceChunk()
- if(distance % 2 > 0) then
- TurnLeft()
- TurnLeft()
- DigForward()
- TurnRight()
- Dig()
- PlaceChunkFront()
- TurnRight()
- DigForward()
- else
- if(chunkCounter == chunk) then
- TurnLeft()
- MoveForward()
- TurnRight()
- Dig()
- PlaceChunk()
- TurnRight()
- DigForward()
- TurnLeft()
- else
- TurnLeft()
- TurnLeft()
- DigForward()
- TurnLeft()
- Dig()
- PlaceChunkFront()
- TurnLeft()
- DigForward()
- end
- end
- end
- function FirstRow()
- CheckFuel()
- turtle.digDown()
- MoveDown()
- PlaceChunkUp()
- for i = 1 , 12 do
- turtle.digDown()
- MoveDown()
- end
- for i = 1 , 7 do
- DigForward()
- DigUp()
- if(i == 1) then
- if(distance % 2 > 0) then
- if(chunkCounter > 1) then
- TurnLeft()
- turtle.dig()
- TurnRight()
- end
- else
- if(chunkCounter > 1) then
- TurnRight()
- turtle.dig()
- TurnLeft()
- end
- end
- end
- DigForward()
- DigDown()
- end
- DigForward()
- DigUp()
- end
- function LastRowNO()
- TurnRight()
- DigForward()
- TurnRight()
- AnyRowFromUp()
- end
- function LastRowOZ()
- TurnLeft()
- DigForward()
- TurnLeft()
- AnyRowFromUp()
- end
- function AnyRowFromUp()
- for i = 1 , 7 do
- DigDown()
- DigForward()
- DigUp()
- DigForward()
- if(turtle.getItemCount(10) > 1) then
- DumpInventory()
- end
- end
- DigDown()
- DigForward()
- DigUp()
- end
- function RetrieveChunkRight()
- TurnRight()
- for i = 1, 14 do
- DigForward()
- end
- turtle.dig()
- TurnRight()
- TurnRight()
- for i = 1, 14 do
- DigForward()
- end
- TurnRight()
- end
- function RetrieveChunkLeft()
- TurnLeft()
- for i = 1, 14 do
- DigForward()
- end
- turtle.dig()
- TurnRight()
- TurnRight()
- for i = 1, 14 do
- DigForward()
- end
- TurnLeft()
- end
- function NO()
- FirstRow()
- if(chunkCounter == 1) then
- TurnLeft()
- turtle.dig()
- TurnRight()
- end
- for y = 1 , 7 do
- TurnRight()
- DigForward()
- TurnRight()
- AnyRowFromUp()
- TurnLeft()
- DigForward()
- TurnLeft()
- AnyRowFromUp()
- end
- LastRowNO()
- PlaceChunk()
- PlaceChunkBack()
- RetrieveChunkRight()
- end
- function OZ()
- FirstRow()
- for y = 1 , 7 do
- TurnLeft()
- DigForward()
- TurnLeft()
- AnyRowFromUp()
- if(y == 1) then
- if(chunkCounter == 1) then
- turtle.dig()
- end
- end
- TurnRight()
- DigForward()
- TurnRight()
- AnyRowFromUp()
- end
- LastRowOZ()
- PlaceChunk()
- if(chunkCounter < chunks) then
- PlaceChunkBack()
- RetrieveChunkLeft()
- end
- end
- function Main()
- while(true) do
- print("Mining")
- if(distance % 2 == 0) then
- chunks = chunks + 2
- else
- chunks = chunks - 1
- end
- for i = 1 , chunks do
- chunkCounter = chunkCounter + 1
- if(distance % 2 == 0) then
- OZ()
- if(chunks > chunkCounter) then
- TurnRight()
- end
- DigForward()
- if(chunks > chunkCounter) then
- TurnRight()
- else
- TurnLeft()
- end
- else
- NO()
- TurnLeft()
- DigForward()
- if(chunks > chunkCounter) then
- TurnLeft()
- end
- end
- end
- chunkCounter = 0
- distance = distance + 1
- if(distance == 2) then
- chunks = chunks - 1
- end
- end --while end
- end
- Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement