Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local depth = 0
- local length = 20
- -- pokehole length
- local fuelNeeded = ((length/3)*20) + (length*2) + (depth*2)
- local function checkFuel()
- while (turtle.getFuelLevel() < fuelNeeded) do
- turtle.select(1)
- if (turtle.getItemCount(1) == 0) then
- print("Not enough fuel.")
- return false
- end
- turtle.refuel(1)
- end
- return true
- end
- local function checkTorches()
- if (length / 10 > turtle.getItemCount(2)) then
- print("Not enough torchs.")
- return false
- end
- return true
- end
- local function checkLadders()
- if (turtle.getItemCount(3) < depth) then
- print("Not enough ladders.")
- return false
- end
- return true
- end
- local function placeTorch()
- turtle.select(2)
- turtle.placeDown()
- end
- local function dig()
- while (turtle.detect()) do
- turtle.dig()
- sleep(0.5)
- end
- end
- local function digPokeHoles()
- local i = 0
- turtle.turnRight()
- for i=0, 4 do
- dig()
- turtle.forward()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for i=0, 4 do
- turtle.forward()
- end
- for i=0, 4 do
- dig()
- turtle.forward()
- end
- turtle.turnRight()
- turtle.turnRight()
- for i=0, 4 do
- turtle.forward()
- end
- turtle.turnLeft()
- end
- local function digToDepth()
- local ladder = false
- if (depth > 1) then
- ladder = true
- end
- if (ladder) then
- turtle.turnRight()
- turtle.turnRight()
- end
- local i = 0
- while (i < depth) do
- turtle.digDown()
- turtle.down()
- if (ladder) then
- turtle.dig()
- turtle.select(3)
- turtle.place()
- end
- i = i + 1
- end
- turtle.digDown()
- if (ladder) then
- turtle.down()
- turtle.dig()
- turtle.select(3)
- turtle.place()
- turtle.up()
- turtle.turnRight()
- turtle.turnRight()
- end
- placeTorch()
- digPokeHoles()
- end
- local function digTunnel()
- local i = 0
- local j = 0
- local k = 0
- while (i < length) do
- dig()
- turtle.forward()
- turtle.digDown()
- j = j + 1
- if (j == 10) then
- placeTorch()
- j = 0
- end
- k = k + 1
- if (k % 3 == 0) then
- digPokeHoles()
- k = 0
- end
- i = i + 1
- end
- end
- local function turnAround()
- turtle.turnRight()
- turtle.turnRight()
- end
- local function moveToTunnelStart()
- local i = 0
- for i=1,length do
- turtle.forward()
- end
- end
- local function moveToStartDepth()
- local i = 0
- for i=1,depth do
- turtle.up()
- end
- end
- local function placeSafetyBlock()
- turtle.select(4)
- turtle.placeDown()
- print("Complete.")
- end
- --If not enough fuel, torches or ladders don't do anything.
- if checkFuel() and checkTorches() and checkLadders() then
- digToDepth()
- digTunnel()
- placeTorch()
- turnAround()
- moveToTunnelStart()
- turnAround()
- moveToStartDepth()
- placeSafetyBlock()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement