Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = { ... }
- -- Distance Variable
- local distance = tonumber(args[1])
- -- Fuel needed Variable
- local fuelNeeded = (distance / 2) * 4
- -- Torches needed variable
- local torchNeeded = distance / 10
- -- Check Amount of Fuel Function
- local function checkFuel()
- while (turtle.getFuelLevel() < fuelNeeded) do
- turtle.select(1)
- if (turtle.getItemCount(1) == 0) then
- print("Not enough fuel to complete operation...")
- return false
- end
- turtle.refuel(1)
- end
- return true
- end
- -- Check Amount of Torches Function
- local function checkTorches()
- if (turtle.getItemCount(2) < torchNeeded) then
- print ("Not enough torches to complete operation...")
- return false
- end
- return true
- end
- -- Detect & Dig Function
- local function dig()
- while (turtle.detect()) do
- turtle.dig()
- sleep(0.5)
- end
- end
- -- Move Left & Dig Function
- local function left()
- turtle.forward()
- turtle.digDown()
- turtle.turnLeft()
- end
- -- Move Right & Dig Function
- local function right()
- turtle.forward()
- turtle.digDown()
- turtle.turnRight()
- end
- -- Main Function | Digs Tunnel
- local function digTunnel()
- print("StartUp Complete. Commencing digging operations..")
- local t = 0
- local i = 0
- while (i < distance) do
- dig()
- right()
- dig()
- left()
- dig()
- left()
- dig()
- right()
- t = t + 2
- if (t == 10) then
- turtle.select(2)
- turtle.placeDown()
- t = 0
- end
- i = i + 2
- end
- end
- if checkFuel() and checkTorches() then
- digTunnel()
- end
Advertisement
Add Comment
Please, Sign In to add comment