funkd0ct0r

Untitled

Mar 30th, 2014
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- rW1DX74j
  2. -- n50gd8aN
  3.  
  4. --place turtle in center of hollow hill feature at block 63 (turtle makes 64), coords +- 256,256, facing east
  5.  
  6. --turtle will autofuel from slot 1
  7. --turtle will return to surface after maxSize area has been cleared
  8.  
  9.  
  10. local curX = 0
  11. local curY = 0
  12.  
  13. local maxSize = 48
  14.  
  15. local function foundItem(chest)
  16.  
  17. print("Found a treasure chest!")
  18.  
  19. turtle.digDown()
  20. for slot = 1, 16 do
  21. if turtle.getItemCount(slot) > 0 then
  22. turtle.select(slot)
  23. turtle.dropDown()
  24. sleep(0)
  25. end
  26. end
  27. turtle.select(1)
  28.  
  29. local stacks = 0
  30. while turtle.suck() do
  31. stacks = stacks + 1
  32. sleep(0)
  33. end
  34. turtle.select(16)
  35. turtle.dig()
  36.  
  37. print("Looted " .. stacks .. " items.")
  38.  
  39. --return to surface
  40. for x = 1, 64 do
  41. while not turtle.up() do
  42. turtle.digUp()
  43. sleep(0)
  44. end
  45. end
  46.  
  47. while not turtle.place() do
  48. turtle.dig()
  49. sleep(0)
  50. end
  51. for slot = 1, 16 do
  52. if turtle.getItemCount(slot) > 0 then
  53. turtle.select(slot)
  54. turtle.drop()
  55. sleep(0)
  56. end
  57. end
  58. turtle.select(1)
  59.  
  60. --dig down and continue quarry
  61. for x = 1, 64 do
  62. while not turtle.down() do
  63. turtle.digDown()
  64. sleep(0)
  65. end
  66. end
  67.  
  68. end
  69.  
  70. local function digForward()
  71.  
  72. local chest
  73.  
  74. chest = peripheral.wrap("left")
  75. if chest then
  76. turtle.turnLeft()
  77. foundItem(chest)
  78. turtle.turnRight()
  79. end
  80. chest = peripheral.wrap("front")
  81. if chest then
  82. foundItem(chest)
  83. end
  84. chest = peripheral.wrap("right")
  85. if chest then
  86. turtle.turnRight()
  87. foundItem(chest)
  88. turtle.turnLeft()
  89. end
  90.  
  91.  
  92. while not turtle.forward() do
  93. sleep(0)
  94. turtle.dig()
  95. end
  96. turtle.digDown()
  97. end
  98.  
  99.  
  100. local function main()
  101. -- [ initialization ] [ mainquarry ] [extra for two return trips]
  102. local reqFuel = 32 + ((maxSize / 2 - 8) * 2) + (maxSize * maxSize * 0.33333) + (64 * 4)
  103.  
  104. turtle.select(1)
  105. while turtle.getFuelLevel() < reqFuel do
  106. if not turtle.refuel(1) then
  107. print("Req Fuel: " .. reqFuel .. " Cur Fuel: " .. turtle.getFuelLevel())
  108. sleep(1)
  109. end
  110. end
  111. turtle.dropUp()
  112.  
  113. while turtle.getItemCount(1) > 0 do
  114. print("Remove Excess Fuel")
  115. sleep(1)
  116. end
  117.  
  118. --dig down and position to corner of quarry area
  119.  
  120.  
  121. for x = 1, 32 do
  122. repeat turtle.digDown() sleep(0) until turtle.down()
  123. end
  124. turtle.turnLeft()
  125. for x = 1, (maxSize / 2 - 8) do
  126. turtle.digDown()
  127. repeat turtle.dig() sleep(0) until turtle.forward()
  128. end
  129. turtle.turnLeft()
  130. for x = 1, (maxSize / 2 - 8) do
  131. turtle.digDown()
  132. repeat turtle.dig() sleep(0) until turtle.forward()
  133. end
  134. turtle.turnLeft()
  135. --quarry out the level
  136. curX = 0
  137. curY = 0
  138. while true do
  139. if(curY % 2 == 0) then
  140. digForward()
  141. curX = curX + 1
  142.  
  143. if(curX >= maxSize) then
  144. turtle.turnLeft()
  145. digForward()
  146. digForward()
  147. digForward()
  148. turtle.turnLeft()
  149. curY = curY + 3
  150. end
  151. else
  152. digForward()
  153. curX = curX - 1
  154.  
  155. if(curX <= 0) then
  156. turtle.turnRight()
  157. digForward()
  158. digForward()
  159. digForward()
  160. curY = curY + 3
  161. if(curY > maxSize) then
  162. break
  163. else
  164. turtle.turnRight()
  165. end
  166. end
  167. end
  168. end
  169.  
  170. --return to surface
  171. for x = 1, 64 do
  172. repeat turtle.digUp() sleep(0) until turtle.up()
  173. end
  174.  
  175. end
  176.  
  177.  
  178.  
  179. main()
Advertisement
Add Comment
Please, Sign In to add comment