Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. local args = {...}
  2. local length = tonumber(args[1])
  3. local depth = tonumber(args[2])
  4. local height = tonumber(args[3])
  5. length = length or 3
  6. height = height or 3
  7. depth = depth or 3
  8. local need = length * height * depth
  9. local x = length
  10. local y = height - 1
  11. local z = depth
  12. local check = 1
  13. local bottom = 1
  14. local top = 0
  15. local left = 1
  16. local right = 0
  17. local l = 1
  18. local r = 0
  19. local q = x
  20.  
  21. function fuel(amount)
  22. if turtle.getFuelLevel() < 5 then
  23. turtle.select(16)
  24. turtle.refuel(amount)
  25. turtle.select(1)
  26. end
  27. end
  28.  
  29. function chest()
  30. if turtle.getItemCount(14) >= 1 then
  31. turtle.turnRight(2)
  32. while turtle.detect() do
  33. turtle.dig()
  34. sleep(0.5)
  35. end
  36. turtle.select(15)
  37. turtle.place()
  38. for m=1,14 do
  39. turtle.select(m)
  40. turtle.drop()
  41. end
  42. turtle.select(1)
  43. turtle.turnLeft(2)
  44. end
  45. end
  46.  
  47. function move()
  48. if right == 0 and left == 0 then
  49. while turtle.detect() do
  50. turtle.dig()
  51. sleep(0.75)
  52. end
  53. turtle.forward()
  54. end
  55. if right == 1 then
  56. turtle.turnLeft()
  57. while turtle.detect() do
  58. turtle.dig()
  59. sleep(0.5)
  60. end
  61. turtle.forward()
  62. turtle.turnLeft()
  63. right = 0
  64. end
  65. if left == 1 then
  66. turtle.turnRight()
  67. while turtle.detect() do
  68. turtle.dig()
  69. sleep(0.5)
  70. end
  71. turtle.forward()
  72. turtle.turnRight()
  73. left = 0
  74. end
  75. end
  76.  
  77. function up()
  78. if bottom == 1 then
  79. move()
  80. for a = 1, y do
  81. while turtle.detectUp() do
  82. turtle.digUp()
  83. sleep(0.5)
  84. end
  85. turtle.up()
  86. fuel(1)
  87. chest()
  88. end
  89. end
  90. end
  91.  
  92. function down()
  93. if top == 1 then
  94. move()
  95. for b = 1, y do
  96. while turtle.detectDown() do
  97. turtle.digDown()
  98. sleep(0.25)
  99. end
  100. turtle.down()
  101. fuel(1)
  102. chest()
  103. end
  104. end
  105. end
  106.  
  107. function value()
  108. if bottom == 1 then
  109. bottom = 0
  110. top = 1
  111. else
  112. bottom = 1
  113. top = 0
  114. end
  115. end
  116.  
  117. function switch()
  118. if l == 1 then
  119. left = 0
  120. right = 1
  121. l = 0
  122. r = 1
  123. else
  124. left = 1
  125. right = 0
  126. l = 1
  127. r = 1
  128. end
  129. end
  130.  
  131. function back()
  132. if top == 1 then
  133. for c = 1, y do
  134. while turtle.detectDown() do
  135. turtle.digDown()
  136. sleep(0.25)
  137. end
  138. turtle.down()
  139. end
  140. end
  141. end
  142.  
  143.  
  144. if turtle.getFuelLevel() < need and turtle.getItemCount(16) == 0 then
  145. print("Please add fuel in slot 16")
  146. check = 0
  147. end
  148.  
  149. if need > 500 and turtle.getItemCount(15) == 0 then
  150. print("Please put chests in slot 15")
  151. check = 0
  152. end
  153.  
  154.  
  155. if check == 1 then
  156. print("Digging away")
  157. turtle.turnLeft()
  158. for j = 1, z do
  159. for i = 1, x do
  160. up()
  161. down()
  162. if (i % 5) == 0 and (j % 5) == 0 then
  163. end
  164. value()
  165. if i == q then
  166. switch()
  167. end
  168. end
  169. end
  170. back()
  171. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement