thesonofdarwin

tunnelv3

Jan 11th, 2013
1,273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. term.clear()
  2. term.setCursorPos(1, 1)
  3.  
  4. repeat
  5. print("Enter tunnel length (even digit): ")
  6. tunnellength = read()
  7. until tunnellength % 2 == 0
  8.  
  9. term.clear()
  10. term.setCursorPos(1, 1)
  11.  
  12. print("Place Fuel in Slot 1")
  13. print("Enter number for fuel type: ")
  14. print("")
  15. print("No Fuel Required = 0")
  16. print("Coal/Charcoal/Peat = 1")
  17. print("Coal Coke = 2")
  18. print("Biofuel Can = 3")
  19. print("Coalfuel Can = 4")
  20. fueltype = read()
  21.  
  22. function fueltypeset()
  23. if fueltype == "1" then
  24. fueltype = 80
  25. elseif fueltype == "2" then
  26. fueltype = 160
  27. elseif fueltype == "3" then
  28. fueltype = 520
  29. elseif fueltype == "4" then
  30. fueltype = 1520
  31. end
  32. end
  33. fueltypeset()
  34. term.clear()
  35. term.setCursorPos(1, 1)
  36.  
  37. print("Drop mined cobblestone? 0=No, 1=Yes")
  38. cobblesetting = read()
  39. term.clear()
  40. term.setCursorPos(1, 1)
  41. if cobblesetting == "1" then
  42. if turtle.getItemCount(2) < 1 then
  43. print("Place 1 cobblestone in Slot 2")
  44. print("")
  45. end
  46. end
  47.  
  48. print("Place torches? 0=No, 1=Yes")
  49. print("Place torches in Slot 3")
  50. torchsetting = read()
  51. term.clear()
  52. term.setCursorPos(1, 1)
  53. if torchsetting == "1" then
  54. if turtle.getItemCount(3) < tunnellength/4 then
  55. print("Warning: You will not have enough torches for entire tunnel length.")
  56. print("")
  57. print("")
  58. end
  59. end
  60.  
  61.  
  62. print("Return and deposit items to chest if inventory nears full?")
  63. print("0=No, 1=Yes")
  64. returnsetting  = read()
  65. term.clear()
  66. term.setCursorPos(1, 1)
  67. if returnsetting == "1" then
  68. print("Place chest immediately behind turtle.")
  69. end
  70.  
  71. print("")
  72. print("Begin mining?")
  73. print("0=Cancel Program, Any Key=Yes")
  74. beginmine = read()
  75. if beginmine == "0" then
  76. os.reboot()
  77. end
  78.  
  79. term.clear()
  80. term.setCursorPos(1,1)
  81. print("Tunneling " .. tunnellength .. " blocks, then returning.")
  82. sleep(2)
  83.  
  84. torchpos = 0
  85.  
  86. function progress()
  87. term.setCursorPos(1,3)
  88. print("Progress: " .. torchpos .. " of " .. tunnellength)
  89. end
  90.  
  91. function fuelcheck()
  92.     if turtle.getFuelLevel() ~= "unlimited" then
  93.         if turtle.getFuelLevel()/fueltype < 0.26 then
  94.         turtle.select(1)
  95.         turtle.refuel(1)
  96.         end
  97.     end
  98. end
  99.  
  100. function dropcobble()
  101.     local stackSize = turtle.getItemCount(2)
  102.     if cobblesetting == "1" then
  103.         if turtle.getFuelLevel() ~= "unlimited" then
  104.             if stackSize > 2 then
  105.                 stackSize = stackSize-1
  106.                 turtle.select(2)
  107.                 turtle.drop(stackSize)
  108.                 end
  109.         elseif turtle.getFuelLevel() == "unlimited" then
  110.             if stackSize > 2 then
  111.                     stackSize = stackSize-1
  112.                     turtle.select(2)
  113.                     turtle.drop(stackSize)
  114.                     end
  115.             turtle.select(1)
  116.             if turtle.compareTo(2) then
  117.                 turtle.drop()
  118.                 end
  119.            
  120.             end
  121.         end
  122. end
  123.  
  124.  
  125. function minewallRight()
  126. fuelcheck()
  127. turtle.select(1)
  128. turtle.dig()
  129. moveforward()
  130. turtle.digUp()
  131. turtle.digDown()
  132. turtle.turnRight()
  133. moveforward()
  134. turtle.digDown()
  135. turtle.digUp()
  136. moveforward()
  137. turtle.digDown()
  138. turtle.digUp()
  139. turtle.turnLeft()
  140. torchpos = torchpos + 1
  141. progress()
  142. end
  143.  
  144. function minewallLeft()
  145. fuelcheck()
  146. turtle.select(1)
  147. turtle.dig()
  148. moveforward()
  149. turtle.digUp()
  150. turtle.digDown()
  151. turtle.turnLeft()
  152. moveforward()
  153. turtle.digDown()
  154. turtle.digUp()
  155. moveforward()
  156. turtle.digDown()
  157. turtle.digUp()
  158. turtle.turnRight()
  159. torchpos = torchpos + 1
  160. progress()
  161. end
  162.  
  163. function minecycle()
  164. for z = 1, tunnellength/2 do
  165. minewallRight()
  166. minewallLeft()
  167. placetorch()
  168. end
  169. end
  170.  
  171. function placetorch()
  172.     if torchsetting == "1" then
  173.         if torchpos % 4 == 0 then
  174.         turtle.turnLeft()
  175.         turtle.dig()
  176.         turtle.select(3)
  177.         turtle.place()
  178.         turtle.turnRight()
  179.         dropcobble()
  180.         fuelcheck()
  181.         fullinventory()
  182.         turtle.select(1)
  183.         end
  184.     else
  185.         if torchpos % 4 == 0 then
  186.         dropcobble()
  187.         fuelcheck()
  188.         fullinventory()
  189.         turtle.select(1)
  190.         end
  191.     end
  192. end
  193.  
  194. function moveforward()
  195. while not turtle.forward() do
  196. sleep(0.25)
  197. turtle.dig()
  198. end
  199. end
  200.  
  201. function turtlehome()
  202. for y = 1, tunnellength do
  203. fuelcheck()
  204. moveforward()
  205. end
  206. end
  207.  
  208.  
  209. function fullinventory()
  210. local invcount = 0
  211.     if returnsetting == "1" then
  212.         for c = 4, 16 do
  213.             if turtle.getItemCount(c) > 0 then
  214.             invcount = invcount+1
  215.             end
  216.         end
  217.         if invcount > 12 then
  218.             turtle.turnLeft()
  219.             turtle.turnLeft()
  220.             fuelcheck()
  221.             for f = 1, torchpos+1 do
  222.             moveforward()
  223.             fuelcheck()
  224.             end
  225.             for d = 4, 16 do
  226.             turtle.select(d)
  227.             turtle.dropDown()
  228.             end
  229.             turtle.turnLeft()
  230.             turtle.turnLeft()
  231.             fuelcheck()
  232.             for f = 1, torchpos+1 do
  233.             moveforward()
  234.             fuelcheck()
  235.             end
  236.             invcount = 0
  237.         else
  238.             invcount = 0
  239.         end
  240.     end
  241. end
  242.  
  243.  
  244. fuelcheck()
  245. turtle.digUp()
  246. turtle.up()
  247. minecycle()
  248. turtle.turnLeft()
  249. turtle.turnLeft()
  250. fuelcheck()
  251. turtlehome()
  252. turtle.down()
  253. turtle.turnRight()
  254. turtle.turnRight()
  255. term.setCursorPos(1,5)
  256. print("Mining Successful")
  257. term.setCursorPos(1,7)
Advertisement
Add Comment
Please, Sign In to add comment