Guest User

Untitled

a guest
Feb 2nd, 2013
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.88 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. 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/10 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 minecycle()
  126. for z = 1, tunnellength do
  127. fuelcheck()
  128. turtle.select(1)
  129. turtle.dig()
  130. moveforward()
  131. turtle.digDown()
  132. torchpos = torchpos + 1
  133. placetorch()
  134. progress()
  135. end
  136. end
  137.  
  138. function placetorch()
  139. if torchsetting == "1" then
  140. if torchpos % 10 == 0 then
  141. turtle.turnLeft()
  142. turtle.dig()
  143. turtle.select(3)
  144. turtle.place()
  145. turtle.turnRight()
  146. dropcobble()
  147. fuelcheck()
  148. fullinventory()
  149. turtle.select(1)
  150. end
  151. else
  152. if torchpos % 10 == 0 then
  153. dropcobble()
  154. fuelcheck()
  155. fullinventory()
  156. turtle.select(1)
  157. end
  158. end
  159. end
  160.  
  161. function moveforward()
  162. while not turtle.forward() do
  163. sleep(0.25)
  164. turtle.dig()
  165. end
  166. end
  167.  
  168. function turtlehome()
  169. for y = 1, tunnellength do
  170. fuelcheck()
  171. moveforward()
  172. end
  173. end
  174.  
  175. function drop()
  176. turtle.select(4)
  177. turtle.drop()
  178. turtle.select(5)
  179. turtle.drop()
  180. turtle.select(6)
  181. turtle.drop()
  182. turtle.select(7)
  183. turtle.drop()
  184. turtle.select(8)
  185. turtle.drop()
  186. turtle.select(9)
  187. turtle.drop()
  188. turtle.select(10)
  189. turtle.drop()
  190. turtle.select(11)
  191. turtle.drop()
  192. turtle.select(12)
  193. turtle.drop()
  194. turtle.select(13)
  195. turtle.drop()
  196. turtle.select(14)
  197. turtle.drop()
  198. turtle.select(15)
  199. turtle.drop()
  200. turtle.select(16)
  201. turtle.drop()
  202. end
  203.  
  204.  
  205. function fullinventory()
  206. local invcount = 0
  207. if returnsetting == "1" then
  208. for c = 4, 16 do
  209. if turtle.getItemCount(c) > 0 then
  210. invcount = invcount+1
  211. end
  212. end
  213. if invcount > 12 then
  214. turtle.turnLeft()
  215. turtle.turnLeft()
  216. fuelcheck()
  217. for f = 1, torchpos+1 do
  218. moveforward()
  219. fuelcheck()
  220. end
  221. for d = 4, 16 do
  222. turtle.select(d)
  223. turtle.dropDown()
  224. end
  225. turtle.turnLeft()
  226. turtle.turnLeft()
  227. fuelcheck()
  228. for f = 1, torchpos+1 do
  229. moveforward()
  230. fuelcheck()
  231. end
  232. invcount = 0
  233. else
  234. invcount = 0
  235. end
  236. end
  237. end
  238.  
  239.  
  240. fuelcheck()
  241. turtle.digUp()
  242. turtle.up()
  243. minecycle()
  244. turtle.turnLeft()
  245. turtle.turnLeft()
  246. fuelcheck()
  247. turtlehome()
  248. turtle.down()
  249. drop()
  250. turtle.turnRight()
  251. turtle.turnRight()
  252. term.setCursorPos(1,5)
  253. print("Mining Successful")
  254. term.setCursorPos(1,7)
Advertisement
Add Comment
Please, Sign In to add comment