Advertisement
MrTurtle

Strip/Branch Tunnel Miner

May 25th, 2014
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.48 KB | None | 0 0
  1. print("Loading Robust Turtle API...")
  2. local load = os.loadAPI("t")
  3. if load then
  4.   print("Robust Turtle API loaded.")
  5. else
  6.  print("Robust Turtle API not found in the root directory with filename t")
  7.  print("Attempting to download as t from pastebin...")
  8.  os.sleep(2)
  9.  local response = http.get("http://pastebin.com/raw.php?i= e0UksEtT")
  10.  if response then
  11.     print("Great Success.")    
  12.     local data = response.readAll()
  13.     response.close()
  14.     local file = fs.open("t", "w")
  15.     file.write(data)
  16.     file.close()
  17.     print("Downloaded as t")
  18.     load = os.loadAPI("t")
  19.     if load then
  20.      print("Robust Turtle API installed & loaded.")
  21.     end
  22.  else
  23.     print( "Download Failed. Please Install Manually." )
  24.     return
  25.  end
  26. end
  27.  
  28.  
  29. --Strip Mining/Branch Mining Turtle. Digs a staircase down a user specified depth,
  30. --then digs pairs of tunnels one wide and 5 high.
  31. --turtle places toches every 6 blocks and a floor when there isnt one.
  32. --More efficient than quarrying or excavating with fall hazards
  33.  
  34.  
  35. local torch, stone = {1,3},{4,5}
  36.  
  37. function stonedrop()
  38.     for i=6,16 do --keeps two stacks of cobblestone
  39.         turtle.select(i)
  40.         if turtle.compareTo(stone[1]) then
  41.             t.right()
  42.             t.dig()
  43.             turtle.drop()
  44.             t.left()
  45.         end
  46.     end
  47. end
  48.  
  49. function tunnel(dist)
  50.     local breadcrumb=0
  51.     --digs a 2 high one wide tunnel, placing down blocks
  52.     --if there is no floor
  53.     for i=1, dist do
  54.      if t.forward() then
  55.       breadcrumb = breadcrumb+1
  56.      end
  57.      t.digUp()
  58.      if not turtle.detectDown() then
  59.       t.placeDown(stone[1],stone[2])
  60.      end
  61.     end
  62.     --prepare to dig top part of tunnel
  63.     t.up(3)
  64.     t.digUp()
  65.     t.turnAround()
  66.     local torchcount =5
  67.     --digs a 3 high 1 wide tunnel on top resulting in a 5 high one wide tunnel.
  68.     for i=1, breadcrumb do
  69.      t.forward()
  70.      t.digUp()
  71.      t.digDown()
  72.      torchcount = torchcount+1
  73.      if torchcount == 6 then
  74.       while not t.placeLeft(torch[1],torch[2]) do
  75.         t.down()
  76.        t.placeLeft(stone[1],stone[2])
  77.        t.up()
  78.       end--endwhile
  79.       torchcount = 0
  80.      end--end if
  81.     end--end for
  82.     t.down(3)
  83. end-- function tunnel
  84.  
  85. function stairs(d)
  86.  local torchcount =0
  87.  for i=1, d do
  88.   t.forward()
  89.   t.digUp()
  90.   t.down()
  91.   if not turtle.detectDown() then
  92.    t.placeDown(t.restack(stone[1],stone[2]))
  93.   end
  94.   torchcount = torchcount+1
  95.   if torchcount == 6 then
  96.    while not t.placeRight(t.restack(torch[1],torch[2])) do
  97.     t.down()
  98.     t.placeRight(t.restack(stone[1],stone[2]))
  99.     t.up()
  100.    end--endwhile
  101.    torchcount = 0
  102.   end--end if
  103.  end--end while
  104. end--end function stairs
  105.  
  106.  
  107. term.clear()
  108. term.setCursorPos(1,1)
  109. print(tostring(os.getComputerLabel())..[=[ will dig a staircase and then dig branch tunnels to the left & right.
  110. ]=]..tostring(os.getComputerLabel())..[=[ will return to the bottom of the stairs after mining, not the top.]=])
  111. print([=[Torches are placed on the right for finding your way back easily. If ]=]..os.getComputerLabel()..[=[ does not detect a floor, ]=]..tostring(os.getComputerLabel())..[=[ will place cobblestone.]=])
  112. read()
  113. term.clear()
  114. term.setCursorPos(1,1)
  115. print([==[If digging more than 15 blocks deep, ]==]..tostring(os.getComputerLabel())..[=[ will turn around and dig the branch mine under the staircase to avoid unloaded chunks.]=])
  116. read()
  117. term.clear()
  118. term.setCursorPos(1,1)
  119. print("Place torches in slots 1-3, cobblestone in slots 4&5 and spare fuel in slot 16.")
  120. print("How deep should "..tostring(os.getComputerLabel()).." dig before digging the branch tunnels?")
  121. local depth = term.readNum()
  122. print("How long should each branch be?")
  123. local length = term.readNum()--branch length
  124. print("How many pairs of branches?")
  125. local branch = term.readNum()--branch quantity
  126. print(tostring(os.getComputerLabel()).."'s fuel level is "..turtle.getFuelLevel()..", ok?")
  127. read()
  128. local hall = 0
  129. stairs(depth)
  130.  
  131. if depth > 15 then
  132.     t.right()
  133.     t.forward()
  134.     t.digUp()
  135.     t.right()
  136.     for i=1,6 do
  137.         if t.forward() then
  138.          hall=hall+1
  139.         end
  140.         if i == 4 then
  141.          while not t.placeRight(torch[1],torch[2]) do
  142.             t.down()
  143.             t.placeRight(stone[1],stone[2])
  144.             t.up()
  145.          end--endwhile
  146.         end
  147.         t.digUp()
  148.         if not turtle.detectDown() then
  149.             t.placeDown(stone[1],stone[2])
  150.         end
  151.     end
  152. end
  153.  
  154. for i=1, branch do
  155.     t.left()
  156.     tunnel(length)
  157.     tunnel(length)
  158.     t.right()
  159.     for i=1,3 do
  160.      if i==2 then
  161.       stonedrop()
  162.      end
  163.      if t.forward() then
  164.       hall=hall+1
  165.      end
  166.      t.digUp()
  167.      if not turtle.detectDown() then
  168.       t.placeDown(stone[1],stone[2])
  169.      end
  170.     end
  171.     print(i.." pairs of branches mined.")
  172. end
  173.  
  174. t.back(hall)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement