bmm115

ore quarry derchest

Dec 21st, 2018
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local args = {...}
  2. if args[1] == "-reboot" then
  3. rowLength = args[2]
  4. rows = args[3]
  5. startingY = args[4]
  6. curRow = args[5]
  7. y = args[6]
  8. else
  9. if fs.exists("startup") then
  10. fs.delete("startup")
  11. end
  12. if #args ~= 3 then
  13. print("Usage: dig <row length> <width> <current y>")
  14. error()
  15. end
  16. rowLength = args[1]
  17. rows = args[2]
  18. startingY = args[3]
  19. curRow = 1
  20.  
  21. y = startingY
  22. end
  23. function full()
  24. fullSlots = 0
  25. for i=2,15 do
  26. if turtle.getItemCount(i) > 0 then
  27. fullSlots = fullSlots + 1
  28. end
  29. end
  30. print(fullSlots .. " slots are full")
  31. return(fullSlots == 14)
  32. end
  33.  
  34. function checkFuel()
  35. if turtle.getFuelLevel() < 10 then
  36. turtle.select(1)
  37. turtle.refuel(1)
  38. end
  39. end
  40.  
  41. function digMove()
  42. checkFuel()
  43. while turtle.detect() do
  44. turtle.dig()
  45. os.sleep(0.5)
  46.  
  47. end
  48. turtle.forward()
  49. updateloc()
  50. turtle.digUp()
  51. turtle.digDown()
  52. if full() then
  53. turtle.dig()
  54. turtle.select(16)
  55. turtle.place()
  56. for i = 1,15 do
  57. turtle.select(i)
  58. turtle.drop()
  59. end
  60. turtle.select(16)
  61. turtle.dig()
  62. end
  63. end
  64.  
  65. function turn()
  66. updateloc()
  67. if curRow % 2 == 0 then
  68. turtle.turnRight()
  69. else
  70. turtle.turnLeft()
  71. end
  72. end
  73.  
  74. function dig()
  75. turtle.digDown()
  76. turtle.down()
  77. y = y - 1
  78. updateloc()
  79. if full() then
  80. turtle.dig()
  81. turtle.select(16)
  82. turtle.place()
  83. for i = 1,15 do
  84. turtle.select(i)
  85. turtle.drop()
  86. end
  87. turtle.select(16)
  88. turtle.dig()
  89. updateloc()
  90. end
  91. end
  92.  
  93. function back()
  94. turtle.turnLeft()
  95. for i=1,rows do
  96. checkFuel()
  97. turtle.forward()
  98. updateloc()
  99. end
  100. turtle.turnLeft()
  101. end
  102.  
  103. function up()
  104. for i=1,(startingY - y) do
  105. checkFuel()
  106. turtle.up()
  107. y = y + 1
  108. updateloc()
  109. end
  110. end
  111.  
  112.  
  113. function down(x)
  114. for i=1,x do
  115. checkFuel()
  116. dig(x)
  117. end
  118. end
  119.  
  120. function chest()
  121. turtle.turnLeft()
  122. turtle.turnLeft()
  123. for i=2,16 do
  124. turtle.select(i)
  125. turtle.drop()
  126. end
  127. if turtle.getItemCount(1) < 3 then
  128. turtle.up()
  129. turtle.select(1)
  130. turtle.suck()
  131. turtle.down()
  132. end
  133. turtle.turnRight()
  134. turtle.turnRight()
  135. end
  136.  
  137. function level()
  138. curRow = 1
  139. for i=1,rows do
  140. for i=1,rowLength-1 do
  141. digMove()
  142. updateloc()
  143. end
  144. if curRow == tonumber(rows) then
  145.  
  146. else
  147. turn()
  148. digMove()
  149. turn()
  150. curRow = curRow + 1
  151. updateloc()
  152. end
  153. end
  154. back()
  155. tempY = y
  156. if full() then
  157. turtle.dig()
  158. turtle.select(16)
  159. turtle.place()
  160. for i = 1,15 do
  161. turtle.select(i)
  162. turtle.drop()
  163. end
  164. turtle.select(16)
  165. turtle.dig()
  166. down(3)
  167. else
  168. down(3)
  169. end
  170. turtle.digDown()
  171. end
  172. function updateloc()
  173. w = fs.open("startup","w")
  174. w.writeLine('shell.run("dig -reboot '..rowLength..' '..rows..' '..startingY..' '..curRow..' '..y..'")')
  175. end
  176. function quarry()
  177. if args[1] == "-reboot" then
  178. else
  179. down(2)
  180. end
  181. turtle.digDown()
  182. updateloc()
  183. while y > 2 do
  184. level()
  185. end
  186. up()
  187. fs.delete("startup")
  188. end
  189.  
  190. quarry()
Add Comment
Please, Sign In to add comment