Advertisement
Guest User

New Branch Mining Program

a guest
Dec 15th, 2012
2,884
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Getting the variables
  2. local tArgs = { ... }
  3. if #tArgs < 1 then
  4.     print("Usage: branch <length> <branches> <torches>")
  5.     return true
  6. end
  7. steps = tonumber(tArgs[1])
  8. branches = tonumber(tArgs[2])
  9. if #tArgs >= 3 and tArgs[3] == "nt" then
  10.     torch = false
  11. else
  12.     torch = true
  13. end
  14.  
  15. -- figure out how long to tunnel to accomodate the number of branches
  16. tunnellength = branches * 4
  17. tunnelprogram = "tunnel"
  18.  
  19. shell.run(tunnelprogram,tunnellength)
  20.  
  21. -- tunnel completed, turn around and return to the beginning branch
  22. turtle.turnLeft()
  23. turtle.forward()
  24. turtle.turnLeft()
  25.  
  26. tunnelreturn = tunnellength - 1
  27.  
  28. for x = 1, tunnelreturn do
  29.     turtle.forward()
  30. end
  31.  
  32. turtle.turnRight()
  33.  
  34. for z = 1, 2 do
  35.     if z ~= 1 then
  36.         -- left side complete, reposition for the right side
  37.         turtle.forward()
  38.         turtle.forward()
  39.         turtle.turnRight()
  40.         turtle.forward()
  41.         turtle.forward()
  42.         turtle.turnLeft()
  43.         turtle.down()
  44.     end
  45.     -- should now be at the start, do the correct number of branches
  46.     for y = 1, branches do
  47.         if y ~= 1 then
  48.             turtle.turnLeft()
  49.             turtle.forward()
  50.             turtle.forward()
  51.             turtle.forward()
  52.             turtle.forward()
  53.             turtle.turnLeft()
  54.             turtle.down()
  55.         end
  56.         --Starting the dig
  57.         for x = 1, steps do
  58.             if not turtle.forward() then
  59.                 repeat
  60.                     turtle.dig()
  61.                     sleep(0.6)
  62.                 until turtle.forward()
  63.             end
  64.         end
  65.         --Getting into position for the return
  66.         turtle.digUp()
  67.         turtle.up()
  68.         turtle.turnRight()
  69.         turtle.turnRight()
  70.         --Starting the return
  71.         for x = 1, steps do
  72.             if torch and x % 8 == 0 then
  73.                 turtle.placeDown()
  74.             end
  75.             if not turtle.forward() then
  76.                 repeat
  77.                     turtle.dig()
  78.                     sleep(0.25)    
  79.                 until turtle.forward()
  80.             end
  81.         end
  82.         -- dump all items from all slots apart from slot 1
  83.         for v = 2, 16 do
  84.             turtle.select(v)
  85.             turtle.drop()
  86.         end
  87.         turtle.select(1)
  88.     end
  89. end
  90.  
  91. -- go to the start ready for another tunnel
  92. turtle.forward()
  93. turtle.down()
  94. turtle.turnRight()
  95. tunnelend = tunnellength + 1
  96. for y = 1, tunnelend do
  97.     turtle.forward()
  98. end
  99. if not turtle.forward() then
  100.     repeat
  101.         turtle.dig()
  102.         sleep(0.6)
  103.     until turtle.forward()
  104. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement