Advertisement
Guest User

v4

a guest
Dec 19th, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.07 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/4 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.  
  169. turtle.dig()
  170. moveforward()
  171. turtle.digUp()
  172. turtle.digDown()
  173.  
  174. turtle.dig()
  175. moveforward()
  176. turtle.digUp()
  177. turtle.digDown()
  178.  
  179. turtle.dig()
  180. moveforward()
  181. turtle.digUp()
  182. turtle.digDown()
  183.  
  184. turtle.dig()
  185. moveforward()
  186. turtle.digUp()
  187. turtle.digDown()
  188.  
  189. turtle.dig()
  190. moveforward()
  191. turtle.digUp()
  192. turtle.digDown()
  193.  
  194. turtle.dig()
  195. moveforward()
  196. turtle.digUp()
  197. turtle.digDown()
  198.  
  199. turtle.dig()
  200. moveforward()
  201. turtle.digUp()
  202. turtle.digDown()
  203.  
  204. turtle.dig()
  205. moveforward()
  206. turtle.digUp()
  207. turtle.digDown()
  208.  
  209. turtle.dig()
  210. moveforward()
  211. turtle.digUp()
  212. turtle.digDown()
  213.  
  214. turtle.turnLeft()
  215. torchpos = torchpos + 1
  216. progress()
  217. end
  218.  
  219. function minewallLeft()
  220. fuelcheck()
  221. turtle.select(1)
  222. turtle.dig()
  223. moveforward()
  224. turtle.digUp()
  225. turtle.digDown()
  226. turtle.turnLeft()
  227. moveforward()
  228. turtle.digDown()
  229. turtle.digUp()
  230. moveforward()
  231. turtle.digDown()
  232. turtle.digUp()
  233.  
  234. turtle.dig()
  235. moveforward()
  236. turtle.digUp()
  237. turtle.digDown()
  238.  
  239. turtle.dig()
  240. moveforward()
  241. turtle.digUp()
  242. turtle.digDown()
  243.  
  244. turtle.dig()
  245. moveforward()
  246. turtle.digUp()
  247. turtle.digDown()
  248.  
  249. turtle.dig()
  250. moveforward()
  251. turtle.digUp()
  252. turtle.digDown()
  253.  
  254. turtle.dig()
  255. moveforward()
  256. turtle.digUp()
  257. turtle.digDown()
  258.  
  259. turtle.dig()
  260. moveforward()
  261. turtle.digUp()
  262. turtle.digDown()
  263.  
  264.  
  265. turtle.turnRight()
  266. torchpos = torchpos + 1
  267. progress()
  268. end
  269.  
  270. function minecycle()
  271. for z = 1, tunnellength/2 do
  272. minewallRight()
  273. minewallLeft()
  274. placetorch()
  275. end
  276. end
  277.  
  278. function placetorch()
  279. if torchsetting == "1" then
  280. if torchpos % 4 == 0 then
  281. turtle.turnLeft()
  282. turtle.dig()
  283. turtle.select(3)
  284. turtle.place()
  285. turtle.turnRight()
  286. dropcobble()
  287. fuelcheck()
  288. fullinventory()
  289. turtle.select(1)
  290. end
  291. else
  292. if torchpos % 4 == 0 then
  293. dropcobble()
  294. fuelcheck()
  295. fullinventory()
  296. turtle.select(1)
  297. end
  298. end
  299. end
  300.  
  301. function moveforward()
  302. while not turtle.forward() do
  303. sleep(0.25)
  304. turtle.dig()
  305. end
  306. end
  307.  
  308. function turtlehome()
  309. for y = 1, tunnellength do
  310. fuelcheck()
  311. moveforward()
  312. end
  313. end
  314.  
  315.  
  316. function fullinventory()
  317. local invcount = 0
  318. if returnsetting == "1" then
  319. for c = 4, 16 do
  320. if turtle.getItemCount(c) > 0 then
  321. invcount = invcount+1
  322. end
  323. end
  324. if invcount > 12 then
  325. turtle.turnLeft()
  326. turtle.turnLeft()
  327. fuelcheck()
  328. for f = 1, torchpos+1 do
  329. moveforward()
  330. fuelcheck()
  331. end
  332. for d = 4, 16 do
  333. turtle.select(d)
  334. turtle.dropDown()
  335. end
  336. turtle.turnLeft()
  337. turtle.turnLeft()
  338. fuelcheck()
  339. for f = 1, torchpos+1 do
  340. moveforward()
  341. fuelcheck()
  342. end
  343. invcount = 0
  344. else
  345. invcount = 0
  346. end
  347. end
  348. end
  349.  
  350. function depositcomplete()
  351. if dcomplete == "1" then
  352. for d = 1, 16 do
  353. turtle.select(d)
  354. turtle.drop()
  355. end
  356. end
  357. end
  358.  
  359. function terminatecomplete()
  360. if tcomplete =="1" then
  361. turtle.down()
  362. os.reboot()
  363. sleep(3)
  364. end
  365. end
  366.  
  367. fuelcheck()
  368. turtle.digUp()
  369. turtle.up()
  370. minecycle()
  371. terminatecomplete()
  372. turtle.turnLeft()
  373. turtle.turnLeft()
  374. fuelcheck()
  375. turtlehome()
  376. turtle.down()
  377. depositcomplete()
  378. turtle.turnRight()
  379. turtle.turnRight()
  380. term.setCursorPos(1,5)
  381. print("Mining Successful")
  382. term.setCursorPos(1,7)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement