Advertisement
Guest User

ross

a guest
Oct 16th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.24 KB | None | 0 0
  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. print("** Ensure these work in your version")
  21. fueltype = read()
  22.  
  23. function fueltypeset()
  24. if fueltype == "1" then
  25. fueltype = 80
  26. elseif fueltype == "2" then
  27. fueltype = 160
  28. elseif fueltype == "3" then
  29. fueltype = 520
  30. elseif fueltype == "4" then
  31. fueltype = 1520
  32. end
  33. end
  34. fueltypeset()
  35. term.clear()
  36. term.setCursorPos(1, 1)
  37.  
  38. print("Drop mined cobblestone? 0=No, 1=Yes")
  39. cobblesetting = read()
  40. term.clear()
  41. term.setCursorPos(1, 1)
  42. if cobblesetting == "1" then
  43. if turtle.getItemCount(2) < 1 then
  44. print("Place 1 cobblestone in Slot 2")
  45. print("")
  46. end
  47. end
  48.  
  49. print("Place torches? 0=No, 1=Yes")
  50. print("Place torches in Slot 3")
  51. torchsetting = read()
  52. term.clear()
  53. term.setCursorPos(1, 1)
  54. if torchsetting == "1" then
  55. if turtle.getItemCount(3) < tunnellength/10 then
  56. print("Warning: You will not have enough torches for entire tunnel length.")
  57. print("")
  58. print("")
  59. end
  60. end
  61.  
  62.  
  63. print("Return and deposit items to chest if inventory nears full?")
  64. print("0=No, 1=Yes")
  65. returnsetting  = read()
  66. term.clear()
  67. term.setCursorPos(1, 1)
  68. if returnsetting == "1" then
  69. print("Place chest immediately behind turtle.")
  70. print("")
  71. end
  72.  
  73. print("Deposit inventory into chest upon completion?")
  74. print("0=No, 1=Yes")
  75. dcomplete  = read()
  76. term.clear()
  77. term.setCursorPos(1, 1)
  78. if dcomplete == "1" then
  79. print("Place chest immediately behind turtle.")
  80. print("")
  81. end
  82.  
  83. print("Terminate program once length is reached?")
  84. print("Note: This will prevent the turtle from depositing items into a chest upon completion.")
  85. print("0=No, 1=Yes")
  86. tcomplete  = read()
  87. term.clear()
  88. term.setCursorPos(1, 1)
  89. if tcomplete == "1" then
  90.         if dcomplete == "1" then
  91.         print("Turtle will NOT deposit items upon completion.")
  92.  print("")
  93. end
  94. end
  95.  
  96. print("")
  97. print("Begin mining?")
  98. print("0=Cancel Program, Any Key=Yes")
  99. beginmine = read()
  100. if beginmine == "0" then
  101. os.reboot()
  102. end
  103.  
  104. term.clear()
  105. term.setCursorPos(1,1)
  106. if tcomplete == "1" then
  107.   print("Tunneling " .. tunnellength .. " blocks, then terminating.")
  108.   elseif tcomplete == "0" then
  109.   print("Tunneling " .. tunnellength .. " blocks, then returning.")
  110. end
  111. sleep(2)
  112.  
  113. torchpos = 0
  114.  
  115. function progress()
  116. term.setCursorPos(1,3)
  117. print("Progress: " .. torchpos .. " of " .. tunnellength)
  118. end
  119.  
  120. function fuelcheck()
  121.         if turtle.getFuelLevel() ~= "unlimited" then
  122.                 if turtle.getFuelLevel()/fueltype < 0.26 then
  123.                 turtle.select(1)
  124.                 turtle.refuel(1)
  125.                 end
  126.         end
  127. end
  128.  
  129. function dropcobble()
  130.     local stackSize = turtle.getItemCount(2)
  131.         if cobblesetting == "1" then
  132.                 if turtle.getFuelLevel() ~= "unlimited" then
  133.                         if stackSize > 2 then
  134.                         stackSize = stackSize-1
  135.                         turtle.select(2)
  136.                         turtle.drop(stackSize)
  137.                         end
  138.                 elseif turtle.getFuelLevel() == "unlimited" then
  139.                         if stackSize > 2 then
  140.                                 stackSize = stackSize-1
  141.                                 turtle.select(2)
  142.                                 turtle.drop(stackSize)
  143.                                 end
  144.                         turtle.select(1)
  145.                         if turtle.compareTo(2) then
  146.                                 turtle.drop()
  147.                                 end
  148.  
  149.                         end
  150.                 end
  151. end
  152.  
  153.  
  154. function minewallRight()
  155. fuelcheck()
  156. turtle.select(1)
  157. turtle.dig()
  158. moveforward()
  159. turtle.digUp()
  160. turtle.digDown()
  161. turtle.turnRight()
  162. moveforward()
  163. turtle.digDown()
  164. turtle.digUp()
  165. moveforward()
  166. turtle.digDown()
  167. turtle.digUp()
  168. moveforward()
  169. turtle.digDown()
  170. turtle.digUp()
  171. moveforward()
  172. turtle.digDown()
  173. turtle.digUp()
  174. turtle.turnLeft()
  175. torchpos = torchpos + 1
  176. progress()
  177. end
  178.  
  179. function minewallLeft()
  180. fuelcheck()
  181. turtle.select(1)
  182. turtle.dig()
  183. moveforward()
  184. turtle.digUp()
  185. turtle.digDown()
  186. turtle.turnLeft()
  187. moveforward()
  188. turtle.digDown()
  189. turtle.digUp()
  190. moveforward()
  191. turtle.digDown()
  192. turtle.digUp()
  193. moveforward()
  194. turtle.digDown()
  195. turtle.digUp()
  196. moveforward()
  197. turtle.digDown()
  198. turtle.digUp()
  199. turtle.turnRight()
  200. torchpos = torchpos + 1
  201. progress()
  202. end
  203.  
  204. function minecycle()
  205. for z = 1, tunnellength/2 do
  206. minewallRight()
  207. minewallLeft()
  208. placetorch()
  209. end
  210. end
  211.  
  212. function placetorch()
  213.         if torchsetting == "1" then
  214.                 if torchpos % 10 == 0 then
  215.                 turtle.select(3)
  216.                 turtle.placeDown()
  217.                 fuelcheck()
  218.                 fullinventory()
  219.                 turtle.select(1)
  220.                 end
  221.                 if torchpos % 3 == 0 then
  222.                 dropcobble()
  223.                 end
  224.         else
  225.                 if torchpos % 10 == 0 then
  226.                 dropcobble()
  227.                 fuelcheck()
  228.                 fullinventory()
  229.                 turtle.select(1)
  230.                 end
  231.         end
  232. end
  233.  
  234. function moveforward()
  235. while not turtle.forward() do
  236. sleep(0.25)
  237. turtle.dig()
  238. end
  239. end
  240.  
  241. function turtlehome()
  242. for y = 1, tunnellength do
  243. fuelcheck()
  244. moveforward()
  245. end
  246. end
  247.  
  248.  
  249. function fullinventory()
  250. local invcount = 0
  251.         if returnsetting == "1" then
  252.                 for c = 4, 16 do
  253.                         if turtle.getItemCount(c) > 0 then
  254.                         invcount = invcount+1
  255.                         end
  256.                 end
  257.                 if invcount > 12 then
  258.                         turtle.turnLeft()
  259.                         turtle.turnLeft()
  260.                         fuelcheck()
  261.                         for f = 1, torchpos+1 do
  262.                         moveforward()
  263.                         fuelcheck()
  264.                         end
  265.                         for d = 4, 16 do
  266.                         turtle.select(d)
  267.                         turtle.dropDown()
  268.                         end
  269.                         turtle.turnLeft()
  270.                         turtle.turnLeft()
  271.                         fuelcheck()
  272.                         for f = 1, torchpos+1 do
  273.                         moveforward()
  274.                         fuelcheck()
  275.                         end
  276.                         invcount = 0
  277.                 else
  278.                         invcount = 0
  279.                 end
  280.         end
  281. end
  282.  
  283. function depositcomplete()
  284.         if dcomplete == "1" then
  285.                 for d = 1, 16 do
  286.                         turtle.select(d)
  287.                         turtle.drop()
  288.                 end
  289.         end
  290. end
  291.  
  292. function terminatecomplete()
  293.         if tcomplete =="1" then
  294.                 turtle.down()
  295.                 os.reboot()
  296.   sleep(3)
  297.         end
  298. end
  299.  
  300. fuelcheck()
  301. turtle.digUp()
  302. turtle.up()
  303. minecycle()
  304. terminatecomplete()
  305. turtle.turnLeft()
  306. turtle.turnLeft()
  307. fuelcheck()
  308. turtlehome()
  309. turtle.down()
  310. depositcomplete()
  311. turtle.turnRight()
  312. turtle.turnRight()
  313. term.setCursorPos(1,5)
  314. print("Mining Successful")
  315. term.setCursorPos(1,7)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement