Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Arm length: ")
- local armlength = read()
- print("Iteration: ")
- local iteration = read()
- print("Torch Slot: ")
- local torchslot = tonumber(read())
- print("WiFi Chest Slot: ")
- local chestslot = tonumber(read())
- function fallingBlocksFront()
- while turtle.detect(gravel) == true do
- turtle.dig()
- end
- while turtle.detect(sand) == true do
- turtle.dig()
- end
- end
- function fallingBlocksUpside()
- while turtle.detectUp(gravel) == true do
- turtle.digUp()
- end
- while turtle.detectUp(sand) == true do
- turtle.digUp()
- end
- end
- function noFrontLeft(goback)
- if turtle.detect() == false then
- backLeft(goback)
- return true
- end
- return false
- end
- function noFrontRight(goback)
- if turtle.detect() == false then
- backRight(goback)
- return true
- end
- return false
- end
- function noGround()
- if turtle.detectDown() == false then
- for i = 1, 16 do
- turtle.select(i)
- local data = turtle.getItemDetail()
- if data.name == "minecraft:cobblestone" then
- turtle.placeDown()
- break
- end
- end
- end
- end
- function checkFuel()
- local fuel = turtle.getFuelLevel()
- if fuel < 30 then
- for i = 1, 16 do
- turtle.select(i)
- local data = turtle.getItemDetail()
- local count = turtle.getItemCount()
- if count > 0 then
- if data.name == "minecraft:coal" then
- turtle.refuel()
- break
- end
- end
- end
- end
- local fuel = turtle.getFuelLevel()
- if fuel < 30 then
- print("Not enough fuel")
- error()
- end
- end
- function tryForward()
- while not turtle.forward() do
- turtle.attack()
- sleep(1)
- end
- end
- function tunnleLeft(length)
- turtle.turnLeft()
- for i = 0, length-1 do
- if not(noFrontLeft(i)) then
- turtle.dig()
- fallingBlocksFront()
- tryForward()
- turtle.digUp()
- fallingBlocksUpside()
- noGround()
- else
- break
- end
- if i == length-1 then
- backLeft(length)
- end
- end
- end
- function tunnleRight(length)
- turtle.turnRight()
- for i = 0, length-1 do
- if not(noFrontRight(i)) then
- turtle.dig()
- fallingBlocksFront()
- tryForward()
- turtle.digUp()
- fallingBlocksUpside()
- noGround()
- else
- break
- end
- if i == length-1 then
- backRight(length)
- end
- end
- end
- function tunnle(length)
- for i = 0, length-1 do
- turtle.dig()
- fallingBlocksFront()
- tryForward()
- turtle.digUp()
- fallingBlocksUpside()
- noGround()
- end
- end
- function backLeft(length)
- turtle.turnLeft()
- turtle.turnLeft()
- for i = 1, length do
- tryForward()
- end
- turtle.turnLeft()
- end
- function backRight(length)
- turtle.turnRight()
- turtle.turnRight()
- for i = 1, length do
- tryForward()
- end
- turtle.turnRight()
- end
- function torch(slot)
- turtle.select(slot)
- local data = turtle.getItemCount()
- if data > 0 then
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- end
- function chest()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(chestslot)
- turtle.place()
- for i = 1, 16 do
- if not (i == torchslot or i == chestslot) then
- turtle.select(i)
- local count = turtle.getItemCount()
- if count > 0 then
- turtle.drop(count)
- end
- end
- end
- turtle.select(chestslot)
- turtle.dig()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- for i = 0, iteration do
- checkFuel()
- tunnle(3)
- if(i%15) == 0 then
- chest()
- end
- if (i%3) == 0 then
- torch(torchslot)
- end
- tunnleLeft(armlength)
- tunnleRight(armlength)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement