Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. local depth=30
  2. local bdepth=30
  3. local currentDepth=0
  4. local currentSide="blank"
  5.  
  6. function forward(num1)
  7. for i=1, num1 do
  8. turtle.forward()
  9. end
  10. end
  11.  
  12. function toChest()
  13. local steps = 0
  14. turtle.turnLeft()
  15. turtle.turnLeft()
  16. forward(currentDepth+2)
  17. if currentSide == "Right" then
  18. turtle.turnLeft()
  19. while turtle.detect() == == true do
  20. turtle.forward()
  21. steps = steps + 1
  22. end
  23. for i=1, 15 do
  24. turtle.select(i)
  25. turtle.drop()
  26. end
  27. turtle.turnLeft()
  28. turtle.turnLeft()
  29. forward(steps)
  30. turtle.turnRight()
  31. while turtle.detect() == false do
  32. turtle.forward()
  33. end
  34. else
  35. turtle.turnRight()
  36. while turtle.detect() == == true do
  37. turtle.forward()
  38. steps = steps + 1
  39. end
  40. for i=1, 15 do
  41. turtle.select(i)
  42. turtle.drop()
  43. end
  44. turtle.turnLeft()
  45. turtle.turnLeft()
  46. forward(steps)
  47. turtle.turnLeft()
  48. while turtle.detect() == false do
  49. turtle.forward()
  50. end
  51. end
  52. end
  53.  
  54. function getInv()
  55. local InvCount=0
  56. for i=1, 15 do
  57. InvCount= InvCount + turtle.getItemCount(i)
  58. end
  59. return InvCount
  60. end
  61.  
  62. function checkFullInv(char1)
  63. if char1 == "dig" then
  64. Num1=getInv()
  65. turtle.dig()
  66. num2=getInv()
  67. if num1 == num2 then
  68. toChest()
  69. end
  70. else if char1 == "digup" then
  71. Num1=getInv()
  72. turtle.digUp()
  73. num2=getInv()
  74. if num1 == num2 then
  75. toChest()
  76. end
  77. else if char1 == "digdown" then
  78. Num1=getInv()
  79. turtle.digDown()
  80. num2=getInv()
  81. if num1 == num2 then
  82. toChest()
  83. end
  84. else
  85. print("invalid pass")
  86. end
  87. end
  88.  
  89. ---Turtle will clear one column of blocks
  90. function column()
  91. while turtle.detect() == true do
  92. checkFullInv(dig)
  93. os.sleep(0.15)
  94. end b
  95. turtle.forward()
  96. while turtle.detectUp() == true do
  97. checkFullInv(digup)
  98. os.sleep(0.15)
  99. end
  100. checkFullInv(digdown)
  101. end
  102.  
  103. function line(num1)
  104. for i=1, num1 do
  105. column()
  106. currentDepth= currentDepth + 1
  107. end
  108. currentDepth=0
  109. end
  110.  
  111. ---Turtle needs to create the primary shaft of the mine
  112. ---depth is defined by the user "Depth"
  113. function shaft() ---Shaft is 3x3
  114. turtle.turnRight()
  115. turtle.forward()
  116. turtle.turnLeft()
  117. line(depth)
  118. turtle.turnLeft()
  119. column()
  120. turtle.turnLeft()
  121. line(depth-1)
  122. turtle.turnRight()
  123. column()
  124. turtle.turnRight()
  125. line(depth-1)
  126. end
  127.  
  128. ---function to return back to start location
  129. ---start location will be center of 3x3 on beginning face
  130. function backtoShaftStart()
  131. turtle.turnRight()
  132. turtle.forward()
  133. turtle.turnRight()
  134. forward(depth-1)
  135. turtle.turnRight()
  136. turtle.turnRight()
  137. end
  138.  
  139. ---start branch mine, there will be shaft on each side of the path
  140. ---the branch itself will be 2 blocks on center (BXXB)
  141. ---depth of the branch will be defined by bdepth
  142. function branch()
  143. ---turtle needs to determine howmany branches to make
  144. branchcount= math.floor(depth / 3)
  145. ---turtle to start on right side
  146. turtle.forward()
  147. turtle.turnRight()
  148. turtle.forward()
  149. currentSide="Right"
  150. for x=1, 2 do
  151. for i=1, branchcount do
  152. line(bdepth)
  153. turtle.turnLeft()
  154. turtle.turnLeft()
  155. forward(bdepth+1)
  156. if i < branchcount
  157. turtle.turnRight()
  158. forward(3)
  159. turtle.turnRight()
  160. end
  161. end
  162. turtle.turnLeft()
  163. turtle.turnLeft()
  164. currentSide="Left"
  165. end
  166. turtle.forward()
  167. turtle.turnLeft()
  168. turtle.back()
  169. end
  170. ---initialize the program
  171. ---user input required for bdepth and depth
  172.  
  173. function Main()
  174. ---Start with shaft
  175. shaft()
  176. backtoShaftStart()
  177. branch()
  178. end
  179.  
  180. Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement