thesonofdarwin

tunnel5v1

Jan 6th, 2013
830
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.03 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("Coal/Charcoal/Peat = 1")
  15. print("Coal Coke = 2")
  16. print("Biofuel Can = 3")
  17. print("Coalfuel Can = 4")
  18. fueltype = read()
  19.  
  20. function fueltypeset()
  21. if fueltype == "1" then
  22. fueltype = 80
  23. elseif fueltype == "2" then
  24. fueltype = 160
  25. elseif fueltype == "3" then
  26. fueltype = 520
  27. elseif fueltype == "4" then
  28. fueltype = 1520
  29. end
  30. end
  31. fueltypeset()
  32. turtle.refuel(1)
  33. term.clear()
  34. term.setCursorPos(1, 1)
  35.  
  36. print("Drop mined cobblestone? 0=No, 1=Yes")
  37. cobblesetting = read()
  38. term.clear()
  39. term.setCursorPos(1, 1)
  40. if cobblesetting == "1" then
  41. if turtle.getItemCount(2) < 1 then
  42. print("Place 1 cobblestone in Slot 2")
  43. print("")
  44. end
  45. end
  46.  
  47. print("Place torches? 0=No, 1=Yes")
  48. print("Place torches in Slot 3")
  49. torchsetting = read()
  50. term.clear()
  51. term.setCursorPos(1, 1)
  52. if torchsetting == "1" then
  53. if turtle.getItemCount(3) < tunnellength/4 then
  54. print("Warning: You will not have enough torches for entire tunnel length.")
  55. print("")
  56. print("")
  57. end
  58. end
  59.  
  60.  
  61. print("Return and deposit items to chest if inventory nears full?")
  62. print("0=No, 1=Yes")
  63. returnsetting  = read()
  64. term.clear()
  65. term.setCursorPos(1, 1)
  66. if returnsetting == "1" then
  67. print("Place chest immediately behind turtle.")
  68. end
  69.  
  70. print("")
  71. print("Begin mining? 0=Cancel Program, Any Key=Yes")
  72. beginmine = read()
  73. if beginmine == "0" then
  74. os.reboot()
  75. end
  76.  
  77. term.clear()
  78. term.setCursorPos(1,1)
  79. print("Tunneling " .. tunnellength .. " blocks, then returning.")
  80. sleep(2)
  81.  
  82. torchpos = 0
  83.  
  84. function fuelcheck()
  85. if turtle.getFuelLevel()/fueltype < 0.26 then
  86. turtle.select(1)
  87. turtle.refuel(1)
  88. end
  89. end
  90.  
  91. function dropcobble()
  92.     local stackSize = turtle.getItemCount(2)
  93.     if cobblesetting == "1" then
  94.     if stackSize > 2 then
  95.         stackSize = stackSize-1
  96.         turtle.select(2)
  97.         turtle.drop(stackSize)
  98.     end
  99.     end
  100. end
  101.  
  102.  
  103. function minewallRight()
  104. turtle.select(1)
  105. turtle.dig()
  106. moveforward()
  107. turtle.digUp()
  108. turtle.digDown()
  109. turtle.turnRight()
  110. moveforward()
  111. turtle.digDown()
  112. turtle.digUp()
  113. moveforward()
  114. turtle.digDown()
  115. turtle.digUp()
  116. turtle.turnLeft()
  117. torchpos = torchpos + 1
  118. end
  119.  
  120. function minewallLeft()
  121. turtle.select(1)
  122. turtle.dig()
  123. moveforward()
  124. turtle.digUp()
  125. turtle.digDown()
  126. turtle.turnLeft()
  127. moveforward()
  128. turtle.digDown()
  129. turtle.digUp()
  130. moveforward()
  131. turtle.digDown()
  132. turtle.digUp()
  133. turtle.turnRight()
  134. torchpos = torchpos + 1
  135. end
  136.  
  137. function minecycle()
  138. for z = 1, tunnellength/2 do
  139. minewallRight()
  140. minewallLeft()
  141. placetorch()
  142. end
  143. end
  144.  
  145. function placetorch()
  146.     if torchsetting == "1" then
  147.         if torchpos % 4 == 0 then
  148.         turtle.turnLeft()
  149.         turtle.dig()
  150.         turtle.select(3)
  151.         turtle.place()
  152.         turtle.turnRight()
  153.         dropcobble()
  154.         fuelcheck()
  155.         fullinventory()
  156.         turtle.select(1)
  157.         end
  158.     else
  159.         if torchpos % 4 == 0 then
  160.         dropcobble()
  161.         fuelcheck()
  162.         fullinventory()
  163.         turtle.select(1)
  164.         end
  165.     end
  166. end
  167.  
  168. function moveforward()
  169. while not turtle.forward() do
  170. sleep(0.25)
  171. turtle.dig()
  172. end
  173. end
  174.  
  175. function turtlehome()
  176. for y = 1, tunnellength do
  177. turtle.forward()
  178. end
  179. end
  180.  
  181. function fullinventory()
  182. local invcount = 0
  183.     if returnsetting == "1" then
  184.         for c = 4, 16 do
  185.             if turtle.getItemCount(c) > 0 then
  186.             invcount = invcount+1
  187.             end
  188.         end
  189.         if invcount > 12 then
  190.             turtle.turnLeft()
  191.             turtle.turnLeft()
  192.             fuelcheck()
  193.             for f = 1, torchpos+1 do
  194.             turtle.forward()
  195.             fuelcheck()
  196.             end
  197.             for d = 4, 16 do
  198.             turtle.select(d)
  199.             turtle.dropDown()
  200.             end
  201.             turtle.turnLeft()
  202.             turtle.turnLeft()
  203.             fuelcheck()
  204.             for f = 1, torchpos+1 do
  205.             turtle.forward()
  206.             fuelcheck()
  207.             end
  208.             invcount = 0
  209.         else
  210.             invcount = 0
  211.         end
  212.     end
  213. end
  214.  
  215.  
  216. fuelcheck()
  217. turtle.digUp()
  218. turtle.up()
  219. minecycle()
  220. turtle.turnLeft()
  221. turtle.turnLeft()
  222. fuelcheck()
  223. turtlehome()
  224. turtle.down()
  225. turtle.turnRight()
  226. turtle.turnRight()
  227. print("Mining Successful")
Advertisement
Add Comment
Please, Sign In to add comment