Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

branchMine

By: a guest on Dec 17th, 2012  |  syntax: Lua  |  size: 3.24 KB  |  views: 140  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. print("Enter desired length of tunnels")
  2.  
  3. local branchLength = read()
  4.  
  5. print("Is this turtle on the right:r or left:l")
  6.  
  7. local turtleSide = read()
  8.  
  9. print("How many branches?")
  10.  
  11. local branches = read()
  12.  
  13. local shaftLength = 1
  14.  
  15. local totalLength = shaftLength * 2 + branchLength * 2
  16.  
  17. local fuelStuff = 0
  18.  
  19. function diggyDiggy()
  20.   turtle.forward()
  21.   turtle.digUp()
  22.   turtle.digDown()
  23.   turtle.dig()
  24. end
  25.  
  26. function gravel()
  27.   turtle.detect()
  28.   if turtle.detect() == true then
  29.     diggyDiggy()
  30.     gravelception()
  31.   end
  32. end
  33.  
  34. function gravelception()
  35.   turtle.detect()
  36.   if turtle.detect() == true then
  37.     diggyDiggy()
  38.     gravel()
  39.   end
  40. end
  41.  
  42. function awYiss()
  43.   totalLength = branchLength * 2 + shaftLength * 2
  44.   turtle.getFuelLevel()
  45.   fuelStuff = (totalLength - turtle.getFuelLevel()) / 96
  46.   if fuelStuff < turtle.getItemCount(1) then
  47.     if fuelStuff < 5 then
  48.       if fuelStuff < 4 then
  49.         if fuelStuff < 3 then
  50.           if fuelStuff < 2 then
  51.             if fuelStuff < 1 then
  52.               if fuelStuff < 0 then
  53.               print ("requires no fuel")
  54.               else  
  55.               turtle.refuel(1)
  56.               end
  57.             else
  58.             turtle.refuel(2)
  59.             end
  60.           else
  61.           turtle.refuel(3)
  62.           end
  63.         else
  64.         turtle.refuel(4)
  65.         end
  66.       else
  67.       turtle.refuel(5)
  68.       end
  69.       turtle.dig()
  70.       for i = 1,shaftLength do
  71.         diggyDiggy()
  72.         turtle.detect()
  73.         if turtle.detect() == true then
  74.           gravelception()
  75.         end
  76.       end
  77.       if turtleSide == "r" then
  78.         turtle.turnRight()
  79.       end
  80.       if turtleSide == "l" then
  81.         turtle.turnLeft()
  82.       end
  83.       turtle.dig()
  84.       for i = 1,branchLength do
  85.         diggyDiggy()
  86.         turtle.detect()
  87.         if turtle.detect() == true then
  88.           gravelception()
  89.         end
  90.       end
  91.       turtle.turnRight()
  92.       turtle.turnRight()
  93.       for i = 1,branchLength do
  94.         turtle.forward()
  95.       end
  96.       if turtleSide == "r" then
  97.         turtle.turnLeft()
  98.       end
  99.       if turtleSide == "l" then
  100.         turtle.turnRight()
  101.       end
  102.       for i = 1,shaftLength do
  103.         turtle.forward()
  104.       end
  105.       shaftLength = shaftLength + 3
  106.     else
  107.     print("I declare the distance I must travel to be far too long!")
  108.     end
  109.   else
  110.   print("not enough fuel to continue")
  111.   end
  112. end
  113.  
  114. for i = 1,branches do
  115.   awYiss()
  116.   if turtleSide == "r" then
  117.     turtle.turnLeft()
  118.   end
  119.   if turtleSide == "l" then
  120.     turtle.turnRight()
  121.   end
  122.   turtle.select(2)
  123.   turtle.drop()
  124.   turtle.select(3)
  125.   turtle.drop()
  126.   turtle.select(4)
  127.   turtle.drop()
  128.   turtle.select(5)
  129.   turtle.drop()
  130.   turtle.select(6)
  131.   turtle.drop()
  132.   turtle.select(7)
  133.   turtle.drop()
  134.   turtle.select(8)
  135.   turtle.drop()
  136.   turtle.select(9)
  137.   turtle.drop()
  138.   turtle.select(10)
  139.   turtle.drop()
  140.   turtle.select(11)
  141.   turtle.drop()
  142.   turtle.select(12)
  143.   turtle.drop()
  144.   turtle.select(13)
  145.   turtle.drop()
  146.   turtle.select(14)
  147.   turtle.drop()
  148.   turtle.select(15)
  149.   turtle.drop()
  150.   turtle.select(16)
  151.   turtle.drop()
  152.   turtle.select(1)
  153.   if turtleSide == "r" then
  154.     turtle.turnLeft()
  155.   end
  156.   if turtleSide == "l" then
  157.     turtle.turnRight()
  158.   end
  159. end