Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --ToDo:
- --Make the Torch algorythm better
- --Make it lava and water proof
- --Learn and use the Table thingy for the wasteblocks
- --Log Diamonds
- local distance = 0
- function safeDig() --Prevents the turtle from getting stuck on gravel or sand
- turtle.dig()
- os.sleep(0.5)
- if turtle.detect() == true then
- safeDig()
- end
- end
- function goMining() --Main function
- for i=1,32 do
- if i%6 == 0 then
- branches(0, true)
- elseif i%11 == 0 then
- branches(1, true)
- else
- branches(0, false)
- end
- checkIfFull()
- safeDig()
- turtle.forward()
- distance = distance + 1
- end
- returnToChestEnd()
- end
- function checkFuel() --If the fuel level is under 100 use the coal in slot one to fill yourself up but dont use all of it so the mined coal will still go in slot 1
- if turtle.getFuelLevel() <= 100 then
- turtle.select(1)
- turtle.refuel(turtle.getItemCount(1)-1)
- end
- end
- function dropWaste() --Drops the blocks listed below
- for i=1,16 do
- turtle.select(i)
- if turtle.getItemCount() == 0
- or turtle.getItemDetail().name == "minecraft:cobblestone"
- or turtle.getItemDetail().name == "minecraft:dirt"
- or turtle.getItemDetail().name == "byg:rocky_stone"
- or turtle.getItemDetail().name == "byg:scoria_cobblestone"
- or turtle.getItemDetail().name == "minecraft:gravel"
- or turtle.getItemDetail().name == "create:weathered_limestone"
- or turtle.getItemDetail().name == "byg:soapstone"
- then
- turtle.drop()
- end
- end
- turtle.select(1)
- end
- function placeTorch() --Digs down and places a torch that is in slot 2
- turtle.select(2)
- turtle.digDown()
- turtle.placeDown()
- turtle.select(1)
- end
- function branches(torchPatterns, doIt)
- turtle.turnRight()
- dropWaste()
- for x=1,32 do
- safeDig()
- turtle.forward()
- if torchPatterns == 0 and doIt == true then
- if x/8 == 1 then
- placeTorch()
- elseif x/18 == 1 then
- placeTorch()
- elseif x/28 == 1 then
- placeTorch()
- end
- elseif torchPatterns == 1 and doIt == true then
- if x/3 == 1 then
- placeTorch()
- elseif x/13 == 1 then
- placeTorch()
- elseif x/23 == 1 then
- placeTorch()
- end
- end
- end
- turtle.turnRight()
- turtle.turnRight()
- for x=1,32 do
- turtle.forward()
- end
- dropWaste()
- for x=1,32 do
- safeDig()
- turtle.forward()
- if torchPatterns == 0 and doIt == true then
- if x/8 == 1 then
- placeTorch()
- elseif x/18 == 1 then
- placeTorch()
- elseif x/28 == 1 then
- placeTorch()
- end
- elseif torchPatterns == 1 and doIt == true then
- if x/3 == 1 then
- placeTorch()
- elseif x/13 == 1 then
- placeTorch()
- elseif x/23 == 1 then
- placeTorch()
- end
- end
- end
- turtle.turnRight()
- turtle.turnRight()
- for x=1,32 do
- turtle.forward()
- end
- turtle.turnLeft()
- dropWaste()
- checkFuel()
- end
- function checkIfFull()
- local x = 0
- for i=1,16 do
- if turtle.getItemCount(i)>0 then
- x = x + 1
- end
- end
- if x >= 13 then
- turtle.select(1)
- returnToChest()
- end
- turtle.select(1)
- end
- function returnToChest()
- turtle.turnRight()
- turtle.turnRight()
- if distance > 0 then
- for i=1,distance do
- turtle.forward()
- end
- end
- for x=3,16 do
- turtle.select(x)
- turtle.dropDown(64)
- end
- turtle.turnRight()
- turtle.turnRight()
- for x=1,distance do
- turtle.forward()
- end
- end
- function returnToChestEnd()
- turtle.turnRight()
- turtle.turnRight()
- if distance > 0 then
- for i=1,distance do
- turtle.forward()
- end
- end
- for x=3,16 do
- turtle.select(x)
- turtle.dropDown(64)
- end
- turtle.turnRight()
- turtle.turnRight()
- end
- goMining()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement