assasin172

turtlerer

Nov 4th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.01 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. moveforward()
  169. turtle.digDown()
  170. turtle.digUp()
  171. moveforward()
  172. turtle.digDown()
  173. turtle.digUp()
  174. moveforward()
  175. turtle.digDown()
  176. turtle.digUp()
  177. turtle.turnLeft()
  178. torchpos = torchpos + 1
  179. progress()
  180. end
  181.  
  182. function minewallLeft()
  183. fuelcheck()
  184. turtle.select(1)
  185. turtle.dig()
  186. moveforward()
  187. turtle.digUp()
  188. turtle.digDown()
  189. turtle.turnLeft()
  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. moveforward()
  200. turtle.digDown()
  201. turtle.digUp()
  202. moveforward()
  203. turtle.digDown()
  204. turtle.digUp()
  205. turtle.turnRight()
  206. torchpos = torchpos + 1
  207. progress()
  208. end
  209.  
  210. function minecycle()
  211. for z = 1, tunnellength/2 do
  212. minewallRight()
  213. minewallLeft()
  214. placetorch()
  215. end
  216. end
  217.  
  218. function placetorch()
  219.     if torchsetting == "1" then
  220.         if torchpos % 4 == 0 then
  221.         turtle.turnLeft()
  222.         turtle.dig()
  223.         turtle.select(3)
  224.         turtle.place()
  225.         turtle.turnRight()
  226.         dropcobble()
  227.         fuelcheck()
  228.         fullinventory()
  229.         turtle.select(1)
  230.         end
  231.     else
  232.         if torchpos % 4 == 0 then
  233.         dropcobble()
  234.         fuelcheck()
  235.         fullinventory()
  236.         turtle.select(1)
  237.         end
  238.     end
  239. end
  240.  
  241. function moveforward()
  242. while not turtle.forward() do
  243. sleep(0.25)
  244. turtle.dig()
  245. end
  246. end
  247.  
  248. function turtlehome()
  249. for y = 1, tunnellength do
  250. fuelcheck()
  251. moveforward()
  252. end
  253. end
  254.  
  255.  
  256. function fullinventory()
  257. local invcount = 0
  258.     if returnsetting == "1" then
  259.         for c = 4, 16 do
  260.             if turtle.getItemCount(c) > 0 then
  261.             invcount = invcount+1
  262.             end
  263.         end
  264.         if invcount > 12 then
  265.             turtle.turnLeft()
  266.             turtle.turnLeft()
  267.             fuelcheck()
  268.             for f = 1, torchpos+1 do
  269.             moveforward()
  270.             fuelcheck()
  271.             end
  272.             for d = 4, 16 do
  273.             turtle.select(d)
  274.             turtle.dropDown()
  275.             end
  276.             turtle.turnLeft()
  277.             turtle.turnLeft()
  278.             fuelcheck()
  279.             for f = 1, torchpos+1 do
  280.             moveforward()
  281.             fuelcheck()
  282.             end
  283.             invcount = 0
  284.         else
  285.             invcount = 0
  286.         end
  287.     end
  288. end
  289.  
  290. function depositcomplete()
  291.     if dcomplete == "1" then
  292.         for d = 1, 16 do
  293.             turtle.select(d)
  294.             turtle.drop()
  295.         end
  296.     end
  297. end
  298.  
  299. function terminatecomplete()
  300.     if tcomplete =="1" then
  301.         turtle.down()
  302.         os.reboot()
  303.   sleep(3)
  304.     end
  305. end
  306.  
  307. fuelcheck()
  308. turtle.digUp()
  309. turtle.up()
  310. minecycle()
  311. terminatecomplete()
  312. turtle.turnLeft()
  313. turtle.turnLeft()
  314. fuelcheck()
  315. turtlehome()
  316. turtle.down()
  317. depositcomplete()
  318. turtle.turnRight()
  319. turtle.turnRight()
  320. term.setCursorPos(1,5)
  321. print("Mining Successful")
  322. term.setCursorPos(1,7)
Advertisement
Add Comment
Please, Sign In to add comment