Advertisement
CookieTheMonsta1

Untitled

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