Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Getting the variables
- local tArgs = { ... }
- if #tArgs < 1 then
- print("Usage: branch <length> <branches> <torches>")
- return true
- end
- steps = tonumber(tArgs[1])
- branches = tonumber(tArgs[2])
- if #tArgs >= 3 and tArgs[3] == "nt" then
- torch = false
- else
- torch = true
- end
- -- figure out how long to tunnel to accomodate the number of branches
- tunnellength = branches * 4
- tunnelprogram = "tunnel"
- shell.run(tunnelprogram,tunnellength)
- -- tunnel completed, turn around and return to the beginning branch
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- tunnelreturn = tunnellength - 1
- for x = 1, tunnelreturn do
- turtle.forward()
- end
- turtle.turnRight()
- for z = 1, 2 do
- if z ~= 1 then
- -- left side complete, reposition for the right side
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- turtle.down()
- end
- -- should now be at the start, do the correct number of branches
- for y = 1, branches do
- if y ~= 1 then
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- turtle.down()
- end
- --Starting the dig
- for x = 1, steps do
- if not turtle.forward() then
- repeat
- turtle.dig()
- sleep(0.6)
- until turtle.forward()
- end
- end
- --Getting into position for the return
- turtle.digUp()
- turtle.up()
- turtle.turnRight()
- turtle.turnRight()
- --Starting the return
- for x = 1, steps do
- if torch and x % 8 == 0 then
- turtle.placeDown()
- end
- if not turtle.forward() then
- repeat
- turtle.dig()
- sleep(0.25)
- until turtle.forward()
- end
- end
- -- dump all items from all slots apart from slot 1
- for v = 2, 16 do
- turtle.select(v)
- turtle.drop()
- end
- turtle.select(1)
- end
- end
- -- go to the start ready for another tunnel
- turtle.forward()
- turtle.down()
- turtle.turnRight()
- tunnelend = tunnellength + 1
- for y = 1, tunnelend do
- turtle.forward()
- end
- if not turtle.forward() then
- repeat
- turtle.dig()
- sleep(0.6)
- until turtle.forward()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement