Advertisement
Guest User

tunnelargs [not mine]

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