Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fuel()
- fuelLevel = turtle.getFuelLevel()
- if fuelLevel == "unlimited" or fuelLevel > 10 then
- return
- end
- function tryRefuel()
- for n=4,16 do
- if turtle.getItemCount(n) > 0 then
- turtle.select(n)
- if turtle.refuel(1) then
- print("Fuel: "..turtle.getFuelLevel().."")
- turtle.select(2)
- return true
- end
- end
- end
- turtle.select(2)
- return false
- end
- if not tryRefuel() then
- print( "Add more fuel to continue." )
- while not tryRefuel() do
- sleep(1)
- end
- print( "Resuming Tunnel." )
- end
- end
- function turn()
- turtle.turnRight()
- turtle.turnRight()
- end
- function dig()
- turtle.dig()
- sleep(1)
- end
- function tunnel()
- turtle.digUp()
- turtle.select(2)
- turtle.placeDown()
- turtle.turnLeft()
- turtle.detect()
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.detect()
- turtle.place()
- turtle.turnLeft()
- end
- function torch()
- if distance == 10 then
- turtle.select(2)
- while turtle.up() == false do
- turtle.digUp()
- sleep(1)
- end
- turtle.turnLeft()
- turtle.dig()
- sleep(1)
- while turtle.forward() == false do
- turtle.dig()
- sleep(1)
- end
- turtle.place()
- turtle.placeUp()
- turtle.back()
- turtle.select(3)
- turtle.place()
- turtle.turnRight()
- turtle.down()
- distance = 0
- end
- end
- function chest()
- for n = 5, 16 do
- turtle.getItemCount()
- end
- if not turtle.getItemCount(n) == 0 then
- turn()
- turtle.select(1)
- turtle.place()
- for n = 5, 16 do
- turtle.drop()
- sleep(1)
- end
- turtle.dig()
- turn()
- end
- end
- function back()
- turtle.up()
- turn()
- while j > 1 do
- if turtle.forward() == true then
- fuel()
- j = j - 1
- else
- dig()
- end
- end
- turtle.down()
- turn()
- end
- -- Main-Script --
- print("Slot 1: Enderchest")
- print("Slot 2: Cobblestone")
- print("Slot 3: Torch")
- print("Slot 4: Coal")
- print("Fuel: "..turtle.getFuelLevel().."")
- write("Tunnel length: ")
- length = tonumber(read())
- print("Starting...")
- i = 1
- j = 1
- distance = 1
- while i <= length do
- if turtle.forward() == true then
- fuel()
- chest()
- tunnel()
- torch()
- i = i + 1
- j = j + 1
- distance = distance +1
- else
- dig()
- end
- end
- back()
- print("Done...")
Advertisement
Add Comment
Please, Sign In to add comment