Advertisement
Guest User

test4

a guest
Oct 16th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.05 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/10 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. turtle.turnLeft()
  169. torchpos = torchpos + 1
  170. progress()
  171. end
  172.  
  173. function minewallLeft()
  174. fuelcheck()
  175. turtle.select(1)
  176. turtle.dig()
  177. moveforward()
  178. turtle.digUp()
  179. turtle.digDown()
  180. turtle.turnLeft()
  181. moveforward()
  182. turtle.digDown()
  183. turtle.digUp()
  184. moveforward()
  185. turtle.digDown()
  186. turtle.digUp()
  187. turtle.turnRight()
  188. torchpos = torchpos + 1
  189. progress()
  190. end
  191.  
  192. function minecycle()
  193. for z = 1, tunnellength/2 do
  194. minewallRight()
  195. minewallLeft()
  196. placetorch()
  197. end
  198. end
  199.  
  200. function placetorch()
  201.         if torchsetting == "1" then
  202.                 if torchpos % 10 == 0 then
  203.                 turtle.select(3)
  204.                 turtle.placeDown()
  205.                 fuelcheck()
  206.                 fullinventory()
  207.                 turtle.select(1)
  208.                 end
  209.                 if torchpos % 3 == 0 then
  210.                 dropcobble()
  211.                 end
  212.         else
  213.                 if torchpos % 10 == 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