Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- if #tArgs == 0 then
- print("Usage: <blocks> to create tunnel")
- return
- end
- --Number of blocks to travel to get the lava
- local maxDistance = tArgs[1]
- --local counter for how far the turtle has travle
- local traveled = 0
- --A helper function to try and move forward, it will attempt to dig if it is blocked.
- local function moveForward()
- if turtle.forward() == false then
- --Failed to move, see if we can dig our way forward
- while turtle.dig() do
- --Keep digging till we can't dig any more, in case gravel is falling.
- end
- if turtle.forward() == false then
- print("I am either blocked or out of fuel.")
- return false
- end
- end
- return true
- end
- --A helper function to try and move down, it will attempt to dig if it is blocked.
- local function moveDown()
- if turtle.down() == false then
- --Failed to move, see if we can dig our way down
- turtle.digDown()
- if turtle.down() == false then
- print("I am either blocked or out of fuel.")
- return false
- end
- end
- return true
- end
- --A helper function to try and move down, it will attempt to dig if it is blocked.
- local function moveUp()
- if turtle.up() == false then
- --Failed to move, see if we can dig our way down
- while turtle.digUp() do
- --Keep digging till we can't dig any more, in case gravel is falling.
- end
- if turtle.up() == false then
- print("I am either blocked or out of fuel.")
- return false
- end
- end
- return true
- end
- --A helper function to build safe walls around tunnel.
- local function walls()
- turtle.select(1)
- turtle.placeDown()
- turtle.turnRight()
- turtle.select(2)
- turtle.place()
- moveUp()
- turtle.select(3)
- turtle.place()
- turtle.turnRight()
- turtle.select(4)
- turtle.placeUp()
- turtle.turnRight()
- turtle.select(5)
- turtle.place()
- moveDown()
- turtle.select(6)
- turtle.place()
- turtle.turnRight()
- end
- --Attempt to travel to max distance for getting lava
- for i = 1, maxDistance do
- if moveForward() == false then
- print("Could not move forward the full requested distance, starting U-Turn early.")
- break
- end
- traveled = traveled + 1
- --change to placeing blocks
- walls()
- end
- --Turn around move a block over and get more lava
- moveForward()
- turtle.select(1)
- turtle.placeUp()
- turtle.turnRight()
- moveForward()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- moveForward()
- turtle.turnRight()
- --Travel back the same number of blocks we came
- --
- --Travel back the same number of blocks we came
- for i = 1, traveled do
- if moveForward() == false then
- end
- end
- turtle.turnRight()
- moveForward()
- moveForward()
- turtle.turnRight()
- turtle.turnRight()
- turtle.place()
- turtle.turnLeft()
- print(turtle.getFuelLevel())
Advertisement
Add Comment
Please, Sign In to add comment