Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.72 KB | None | 0 0
  1. term.clear() term.setCursorPos(1, 1)
  2.  
  3. repeat
  4. print("Enter tunnel length (even digit): ")
  5. tunnellength = read()
  6. until tunnellength % 2 == 0
  7.  
  8. term.clear()
  9. term.setCursorPos(1, 1)
  10.  
  11. print("Place Fuel in Slot 1")
  12. print("Enter number for fuel type: ")
  13. print("")
  14. print("No Fuel Required = 0")
  15. print("Coal/Charcoal/Peat = 1")
  16. print("Coal Coke = 2")
  17. print("Biofuel Can = 3 **")
  18. print("Coalfuel Can = 4 **")
  19. print("** Ensure these work in your version")
  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. print("")
  70. end
  71.  
  72. print("Deposit inventory into chest upon completion?")
  73. print("0=No, 1=Yes")
  74. dcomplete = read()
  75. term.clear()
  76. term.setCursorPos(1, 1)
  77. if dcomplete == "1" then
  78. print("Place chest immediately behind turtle.")
  79. print("")
  80. end
  81.  
  82. print("Terminate program once length is reached?")
  83. print("Note: This will prevent the turtle from depositing items into a chest upon completion.")
  84. print("0=No, 1=Yes")
  85. tcomplete = read()
  86. term.clear()
  87. term.setCursorPos(1, 1)
  88. if tcomplete == "1" then
  89. if dcomplete == "1" then
  90. print("Turtle will NOT deposit items upon completion.")
  91. print("")
  92. end
  93. end
  94.  
  95. print("")
  96. print("Begin mining?")
  97. print("0=Cancel Program, Any Key=Yes")
  98. beginmine = read()
  99. if beginmine == "0" then
  100. os.reboot()
  101. end
  102.  
  103. term.clear()
  104. term.setCursorPos(1,1)
  105. if tcomplete == "1" then
  106. print("Tunneling " .. tunnellength .. " blocks, then terminating.")
  107. elseif tcomplete == "0" then
  108. print("Tunneling " .. tunnellength .. " blocks, then returning.")
  109. end
  110. sleep(2)
  111.  
  112. torchpos = 0
  113.  
  114. function progress()
  115. term.setCursorPos(1,3)
  116. print("Progress: " .. torchpos .. " of " .. tunnellength)
  117. end
  118.  
  119. function fuelcheck()
  120. if turtle.getFuelLevel() ~= "unlimited" then
  121. if turtle.getFuelLevel()/fueltype < 0.26 then
  122. turtle.select(1)
  123. turtle.refuel(1)
  124. end
  125. end
  126. end
  127.  
  128. function dropcobble()
  129. local stackSize = turtle.getItemCount(2)
  130. if cobblesetting == "1" then
  131. if turtle.getFuelLevel() ~= "unlimited" then
  132. if stackSize > 2 then
  133. stackSize = stackSize-1
  134. turtle.select(2)
  135. turtle.drop(stackSize)
  136. end
  137. elseif turtle.getFuelLevel() == "unlimited" then
  138. if stackSize > 2 then
  139. stackSize = stackSize-1
  140. turtle.select(2)
  141. turtle.drop(stackSize)
  142. end
  143. turtle.select(1)
  144. if turtle.compareTo(2) then
  145. turtle.drop()
  146. end
  147.  
  148. end
  149. end
  150. end
  151.  
  152.  
  153. function minewallRight()
  154. fuelcheck()
  155. turtle.select(1)
  156. turtle.dig()
  157. moveforward()
  158. turtle.digUp()
  159. turtle.digDown()
  160. turtle.turnRight()
  161. moveforward()
  162. turtle.digDown()
  163. turtle.digUp()
  164. moveforward()
  165. turtle.digDown()
  166. turtle.digUp()
  167. turtle.turnLeft()
  168. torchpos = torchpos + 1
  169. progress()
  170. end
  171.  
  172. function minewallLeft()
  173. fuelcheck()
  174. turtle.select(1)
  175. turtle.dig()
  176. moveforward()
  177. turtle.digUp()
  178. turtle.digDown()
  179. turtle.turnLeft()
  180. moveforward()
  181. turtle.digDown()
  182. turtle.digUp()
  183. moveforward()
  184. turtle.digDown()
  185. turtle.digUp()
  186. turtle.turnRight()
  187. torchpos = torchpos + 1
  188. progress()
  189. end
  190.  
  191. function minecycle()
  192. for z = 1, tunnellength/2 do
  193. minewallRight()
  194. minewallLeft()
  195. placetorch()
  196. end
  197. end
  198.  
  199. function placetorch()
  200. if torchsetting == "1" then
  201. if torchpos % 4 == 0 then
  202. turtle.turnLeft()
  203. turtle.dig()
  204. turtle.select(3)
  205. turtle.place()
  206. turtle.turnRight()
  207. dropcobble()
  208. fuelcheck()
  209. fullinventory()
  210. turtle.select(1)
  211. end
  212. else
  213. if torchpos % 4 == 0 then
  214. dropcobble()
  215. fuelcheck()
  216. fullinventory()
  217. turtle.select(1)
  218. end
  219. end
  220. end
  221.  
  222. function moveforward()
  223. while not turtle.forward() do
  224. sleep(0.25)
  225. turtle.dig()
  226. end
  227. end
  228.  
  229. function turtlehome()
  230. for y = 1, tunnellength do
  231. fuelcheck()
  232. moveforward()
  233. end
  234. end
  235.  
  236.  
  237. function fullinventory()
  238. local invcount = 0
  239. if returnsetting == "1" then
  240. for c = 4, 16 do
  241. if turtle.getItemCount(c) > 0 then
  242. invcount = invcount+1
  243. end
  244. end
  245. if invcount > 12 then
  246. turtle.turnLeft()
  247. turtle.turnLeft()
  248. fuelcheck()
  249. for f = 1, torchpos+1 do
  250. moveforward()
  251. fuelcheck()
  252. end
  253. for d = 4, 16 do
  254. turtle.select(d)
  255. turtle.dropDown()
  256. end
  257. turtle.turnLeft()
  258. turtle.turnLeft()
  259. fuelcheck()
  260. for f = 1, torchpos+1 do
  261. moveforward()
  262. fuelcheck()
  263. end
  264. invcount = 0
  265. else
  266. invcount = 0
  267. end
  268. end
  269. end
  270.  
  271. function depositcomplete()
  272. if dcomplete == "1" then
  273. for d = 1, 16 do
  274. turtle.select(d)
  275. turtle.drop()
  276. end
  277. end
  278. end
  279.  
  280. function terminatecomplete()
  281. if tcomplete =="1" then
  282. turtle.down()
  283. os.reboot()
  284. sleep(3)
  285. end
  286. end
  287.  
  288. fuelcheck()
  289. turtle.digUp()
  290. turtle.up()
  291. minecycle()
  292. terminatecomplete()
  293. turtle.turnLeft()
  294. turtle.turnLeft()
  295. fuelcheck()
  296. turtlehome()
  297. turtle.down()
  298. depositcomplete()
  299. turtle.turnRight()
  300. turtle.turnRight()
  301. term.setCursorPos(1,5)
  302. print("Mining Successful")
  303. term.setCursorPos(1,7)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement