Advertisement
Guest User

computercraft mining turtle strip mine

a guest
May 27th, 2019
2,896
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.50 KB | None | 0 0
  1. -- drop slots are 2 and 13-16, fuel slot is 1, torch slots are 3 and 4
  2.  
  3. print("Enter desired length of tunnels")
  4.  
  5. local branchLength = read()
  6.  
  7. print("Is this turtle on the right:r or left:l")
  8.  
  9. local turtleSide = read()
  10.  
  11. print("How many branches?")
  12.  
  13. local branches = read()
  14.  
  15. local shaftLength = 1
  16.  
  17. local totalLength = shaftLength * 2 + branchLength * 2
  18.  
  19. local fuelStuff = 0
  20.  
  21. local dig_var = 0
  22.  
  23. local exceptions = {2, 13, 14, 15, 16}
  24.  
  25. function exceptionDrop()
  26.   for q=5,12 do
  27.     select(q)
  28.     for p=0,4 do
  29.       if turtle.compareTo(exceptions[p]) then
  30.       turtle.drop()
  31.     end
  32.   end
  33. end
  34.  
  35. function diggyDiggy()
  36.   dig_var = dig_var + 1
  37.   turtle.forward()
  38.   if dig_var == 12 then
  39.     exceptionDrop()
  40.     turtle.select(4)
  41.     turtle.back()
  42.     if turtle.compareTo(3) then
  43.       turtle.placeDown()
  44.     else
  45.       turtle.select(3)
  46.       turtle.placeDown()
  47.     end
  48.     dig_var = 0
  49.     turtle.forward()
  50.   end
  51.   exceptionDrop()
  52.   turtle.digUp()
  53.   turtle.digDown()
  54.   turtle.dig()
  55. end
  56.  
  57. function gravel()
  58.   turtle.detect()
  59.   if turtle.detect() == true then
  60.     diggyDiggy()
  61.     gravelception()
  62.   end
  63. end
  64.  
  65. function gravelception()
  66.   turtle.detect()
  67.   if turtle.detect() == true then
  68.     diggyDiggy()
  69.     gravel()
  70.   end
  71. end
  72.  
  73. function re_fuel(m)
  74.   for k=1,16 do
  75.     turtle.select(k)
  76.     turtle.refuel(m)
  77.   end
  78. end
  79.  
  80. function awYiss()
  81.   totalLength = branchLength * 2 + shaftLength * 2
  82.   turtle.getFuelLevel()
  83.   fuelStuff = (totalLength - turtle.getFuelLevel()) / 96
  84.   if fuelStuff < turtle.getItemCount(1) then
  85.     if fuelStuff < 5 then
  86.       if fuelStuff < 4 then
  87.         if fuelStuff < 3 then
  88.           if fuelStuff < 2 then
  89.             if fuelStuff < 1 then
  90.               if fuelStuff < 0 then
  91.               print ("requires no fuel")
  92.               else  
  93.                 re_fuel(1)
  94.               end
  95.             else
  96.               re_fuel(2)
  97.             end
  98.           else
  99.             re_fuel(3)
  100.           end
  101.         else
  102.           re_fuel(4)
  103.         end
  104.       else
  105.         re_fuel(5)
  106.       end
  107.       turtle.dig()
  108.       for i = 1,shaftLength do
  109.         diggyDiggy()
  110.         turtle.detect()
  111.         if turtle.detect() == true then
  112.           gravelception()
  113.         end
  114.       end
  115.       if turtleSide == "r" then
  116.         turtle.turnRight()
  117.       end
  118.       if turtleSide == "l" then
  119.         turtle.turnLeft()
  120.       end
  121.       turtle.dig()
  122.       for i = 1,branchLength do
  123.         diggyDiggy()
  124.         turtle.detect()
  125.         if turtle.detect() == true then
  126.           gravelception()
  127.         end
  128.       end
  129.       turtle.turnRight()
  130.       turtle.turnRight()
  131.       for i = 1,branchLength do
  132.         turtle.forward()
  133.       end
  134.       if turtleSide == "r" then
  135.         turtle.turnLeft()
  136.       end
  137.       if turtleSide == "l" then
  138.         turtle.turnRight()
  139.       end
  140.       for i = 1,shaftLength do
  141.         turtle.forward()
  142.       end
  143.       shaftLength = shaftLength + 3
  144.     else
  145.     print("I declare the distance I must travel to be far too long!")
  146.     end
  147.   else
  148.   print("not enough fuel to continue")
  149.   end
  150. end
  151.  
  152. for i = 1,branches do
  153.   awYiss()
  154.   if turtleSide == "r" then
  155.     turtle.turnLeft()
  156.   end
  157.   if turtleSide == "l" then
  158.     turtle.turnRight()
  159.   end
  160.   for j=5,12 do
  161.     turtle.select(1)
  162.     if turtle.compareTo(j) ~= true then
  163.       turtle.select(j)
  164.       turtle.drop()
  165.     end
  166.   end
  167.   turtle.select(1)
  168.   if turtleSide == "r" then
  169.     turtle.turnLeft()
  170.   end
  171.   if turtleSide == "l" then
  172.     turtle.turnRight()
  173.   end
  174. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement