Advertisement
Guest User

Untitled

a guest
Dec 17th, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.18 KB | None | 0 0
  1. -- Description: Quarries a 16 x 16 area, and returns to a drop off inventory directly above it's starting location.
  2.  
  3. -- Usage info:
  4. -- 1: type in pastebin get <code at end of url> <desired program name>
  5. -- 2: Place mining turtle in bottom right corner of chunk you want to quarry, put it with in the quarry boundaries.
  6. -- 3: Place chest or other drop off inventory above the turtle.
  7. -- 4: Place fuel in slot one of turtle.
  8. -- 5: Run program, and come back to see the hole later.
  9.  
  10. -- Variable declaration zone
  11. local level = 0 -- Level turtle just completed
  12. local currentLevel = 0 -- Level turtle is currently on
  13. local layer = 0 -- Layers dug
  14. local direction = "right" -- Direction turtle must turn in next
  15. local x = 1 -- x location
  16. local z = 1 -- z location
  17. local noBedrock = true
  18. local slot = 1
  19. local goHome = 0
  20. -- End variable declaration zone
  21.  
  22. -- Function delaration zone
  23. -- Refuel script
  24. function refuel()
  25. print("Checking fuel...")
  26. if turtle.getFuelLevel() < 500 then
  27. print("Refueling. Only ", turtle.getFuelLevel(), " left.")
  28. turtle.select(1)
  29. turtle.refuel(15)
  30. print("Fuel inceased to: ", turtle.getFuelLevel())
  31. end
  32. end
  33. -- Digs a layer
  34. function digLayer()
  35. print("Preparing to dig...")
  36. for x = 1,16 do
  37. -- Digs a 16 block long line
  38. for z = 1,15 do
  39. turtle.dig()
  40. while turtle.attack() do
  41. sleep(1)
  42. end
  43. turtle.forward()
  44. end
  45. -- Determines if it needs to turn left or right to dig the next row
  46. if direction == "left" and x ~= 16 then
  47. turtle.turnLeft()
  48. turtle.dig()
  49. while turtle.attack() do
  50. sleep(1)
  51. end
  52. turtle.forward()
  53. turtle.turnLeft()
  54. direction = "right"
  55. elseif direction == "right" and x ~= 16 then
  56. turtle.turnRight()
  57. turtle.dig()
  58. while turtle.attack() do
  59. sleep(1)
  60. end
  61. turtle.forward()
  62. turtle.turnRight()
  63. direction = "left"
  64. end
  65. end
  66. print("Layer complete.")
  67. end
  68. -- Checks for bedrock
  69. function checkBedrock()
  70. print("Checking for bedrock...")
  71. if turtle.digDown() == true then
  72. turtle.select(2)
  73. turtle.placeDown()
  74. print("Not yet at bedrock.")
  75. elseif turtle.up() == true then
  76. turtle.down()
  77. print("Not yet at bedrock.")
  78. else
  79. noBedrock = false
  80. print("At bedrock.")
  81. end
  82. end
  83. -- Returns to home location to drop off resources
  84. function dropOff()
  85. print("Preparing dropoff sequence...")
  86. -- Return home location
  87. print("Returning home...")
  88. turtle.turnRight()
  89. for goHome = 1,15 do
  90. while turtle.attack() do
  91. sleep(1)
  92. end
  93. turtle.forward()
  94. end
  95. -- Rises to the surface to drop items off
  96. level = 0
  97. while turtle.attackDown() do
  98. sleep(1)
  99. end
  100. while turtle.down() do
  101. level = level + 1
  102. while turtle.attackDown() do
  103. sleep(1)
  104. end
  105. end
  106. -- Empties inventory into drop off
  107. print("Preparing to empty inventory...")
  108. for slot = 2,16 do
  109. turtle.select(slot)
  110. turtle.dropDown()
  111. end
  112. print("Inventory cleared. All items dropped off.")
  113. -- Goes back down to desired layer
  114. print("Returning to correct floor...")
  115. currentLevel = 0
  116. while turtle.attackDown() do
  117. sleep(1)
  118. end
  119. while level ~= currentLevel do
  120. turtle.down()
  121. while turtle.attackDown() do
  122. sleep(1)
  123. end
  124. currentLevel = currentLevel + 1
  125. end
  126. print("Back at correct floor.")
  127. end
  128. -- Ending sequence
  129. function endSequence()
  130. print("Starting end sequence...")
  131. while turtle.attackDown() do
  132. sleep(1)
  133. end
  134. while turtle.up() do
  135. while turtle.attackUp() do
  136. sleep(1)
  137. end
  138. end
  139. print("Total number of layers dug: ", layer)
  140. print("Mission complete. Master shall not punish me.")
  141. end
  142. -- Layer preparation
  143. function layerPrep()
  144. print("Preforming next layer preparation...")
  145. turtle.turnRight()
  146. direction = "right"
  147. turtle.digDown()
  148. turtle.down()
  149. print("Next layer prepared")
  150. end
  151. -- End function declaration zone
  152.  
  153. -- Main running sequence
  154. while noBedrock do
  155. refuel()
  156. checkBedrock()
  157. if noBedrock == true then
  158. digLayer()
  159. dropOff()
  160. layerPrep()
  161. end
  162. layer = layer + 1
  163. end
  164. endSequence()
  165. -- End main running sequence
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement