Advertisement
Post_maphone

Quarry

Nov 29th, 2020 (edited)
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. xCoord = -80
  2.  
  3. zCoord = 321
  4.  
  5. yCoord = 80
  6.  
  7.  
  8.  
  9. xQuarry = 999
  10.  
  11. zQuarry = 999
  12.  
  13. yQuarry = 150
  14.  
  15.  
  16.  
  17. xProgress = 999
  18.  
  19. zProgress = 999
  20.  
  21. yProgress = 150
  22.  
  23. oProgress = 1
  24.  
  25.  
  26.  
  27. xHome = xCoord
  28.  
  29. zHome = zCoord
  30.  
  31. yHome = yCoord
  32.  
  33.  
  34.  
  35. yTravel = 85
  36.  
  37.  
  38.  
  39. orientation = 4
  40.  
  41. orientations = {"north", "east", "south", "west"}
  42.  
  43.  
  44.  
  45. zDiff = {-1, 0, 1, 0}
  46.  
  47. xDiff = {0, 1, 0, -1}
  48.  
  49.  
  50.  
  51. lineLength = 5
  52.  
  53. lines = 5
  54.  
  55.  
  56. yMin = 999
  57.  
  58.  
  59.  
  60. function inventoryFull()
  61.  
  62. turtle.select(9)
  63.  
  64. full = turtle.getItemCount(9) > 0
  65.  
  66. turtle.select(1)
  67.  
  68. return full
  69.  
  70. end
  71.  
  72.  
  73.  
  74. function left()
  75.  
  76. orientation = orientation - 1
  77.  
  78. orientation = (orientation - 1) % 4
  79.  
  80. orientation = orientation + 1
  81.  
  82.  
  83. turtle.turnLeft()
  84.  
  85. end
  86.  
  87.  
  88.  
  89. function right()
  90.  
  91. orientation = orientation - 1
  92.  
  93. orientation = (orientation + 1) % 4
  94.  
  95. orientation = orientation + 1
  96.  
  97.  
  98. turtle.turnRight()
  99.  
  100. end
  101.  
  102.  
  103.  
  104. function moveForward()
  105.  
  106. xCoord = xCoord + xDiff[orientation]
  107.  
  108. zCoord = zCoord + zDiff[orientation]
  109.  
  110.  
  111. turtle.dig()
  112.  
  113.  
  114. moved = false
  115.  
  116. while not(moved) do
  117.  
  118. moved = turtle.forward()
  119.  
  120. end
  121.  
  122. end
  123.  
  124.  
  125.  
  126. function moveUp()
  127.  
  128. yCoord = yCoord + 1
  129.  
  130.  
  131. turtle.digUp()
  132.  
  133.  
  134. moved = false
  135.  
  136. while not(moved) do
  137.  
  138. moved = turtle.up()
  139.  
  140. end
  141.  
  142. end
  143.  
  144.  
  145.  
  146. function moveDown()
  147.  
  148. yCoord = yCoord - 1
  149.  
  150.  
  151. turtle.digDown()
  152.  
  153.  
  154.  
  155. moved = false
  156.  
  157. while not(moved) do
  158.  
  159. moved = turtle.down()
  160.  
  161. end
  162.  
  163.  
  164.  
  165. if yMin > yCoord then
  166.  
  167. yMin = yCoord
  168.  
  169. end
  170.  
  171. end
  172.  
  173.  
  174.  
  175. function look(direction)
  176.  
  177. while direction ~= orientations[orientation] do
  178.  
  179. right()
  180.  
  181. end
  182.  
  183. end
  184.  
  185.  
  186.  
  187. function goto(xTarget, zTarget, yTarget)
  188.  
  189. while yTarget < yCoord do
  190.  
  191. moveDown()
  192.  
  193. end
  194.  
  195.  
  196. while yTarget > yCoord do
  197.  
  198. moveUp()
  199.  
  200. end
  201.  
  202.  
  203.  
  204. if xTarget < xCoord then
  205.  
  206. look("west")
  207.  
  208. while xTarget < xCoord do
  209.  
  210. moveForward()
  211.  
  212. end
  213.  
  214. end
  215.  
  216. if xTarget > xCoord then
  217.  
  218. look("east")
  219.  
  220. while xTarget > xCoord do
  221.  
  222. moveForward()
  223.  
  224. end
  225.  
  226. end
  227.  
  228.  
  229.  
  230. if zTarget < zCoord then
  231.  
  232. look("north")
  233.  
  234. while zTarget < zCoord do
  235.  
  236. moveForward()
  237.  
  238. end
  239.  
  240. end
  241.  
  242. if zTarget > zCoord then
  243.  
  244. look("south")
  245.  
  246. while zTarget > zCoord do
  247.  
  248. moveForward()
  249.  
  250. end
  251.  
  252. end
  253.  
  254. end
  255.  
  256.  
  257.  
  258. function returnItems()
  259.  
  260. xProgress = xCoord
  261.  
  262. zProgress = zCoord
  263.  
  264. yProgress = yCoord
  265.  
  266. oProgress = orientation
  267.  
  268.  
  269.  
  270. goto(xHome, zHome, yTravel)
  271.  
  272. goto(xHome, zHome, yHome)
  273.  
  274.  
  275. for i = 1,9 do
  276.  
  277. turtle.select(i)
  278.  
  279. turtle.drop()
  280.  
  281. end
  282.  
  283. turtle.select(1)
  284.  
  285.  
  286.  
  287. goto(xProgress, zProgress, yTravel)
  288.  
  289. goto(xProgress, zProgress, yProgress)
  290.  
  291. look(orientations[oProgress])
  292.  
  293. end
  294.  
  295.  
  296.  
  297. function digLine()
  298.  
  299. for i = 1,lineLength do
  300.  
  301. if inventoryFull() then
  302.  
  303. returnItems()
  304.  
  305. end
  306.  
  307.  
  308. moveForward()
  309.  
  310. end
  311.  
  312. end
  313.  
  314.  
  315.  
  316. function digLayer()
  317.  
  318. for i = 1,lines do
  319.  
  320. digLine()
  321.  
  322. if (i%2) == 1 and i < lines then
  323.  
  324. left()
  325.  
  326. moveForward()
  327.  
  328. left()
  329.  
  330. elseif i < lines then
  331.  
  332. right()
  333.  
  334. moveForward()
  335.  
  336. right()
  337.  
  338. end
  339.  
  340. end
  341.  
  342.  
  343. goto(xQuarry, zQuarry, yCoord)
  344.  
  345. look("north")
  346.  
  347. moveDown()
  348.  
  349. end
  350.  
  351.  
  352.  
  353. function digQuarry(xTarget, zTarget, yTarget)
  354.  
  355. xQuarry = xTarget
  356.  
  357. zQuarry = zTarget
  358.  
  359. yQuarry = yTarget
  360.  
  361.  
  362.  
  363. goto(xQuarry, zQuarry, yTravel)
  364.  
  365. goto(xQuarry, zQuarry, yQuarry)
  366.  
  367. look("north")
  368.  
  369.  
  370. while yMin > 7 do
  371.  
  372. digLayer()
  373.  
  374. end
  375.  
  376.  
  377. goto(xQuarry, zQuarry, yQuarry)
  378.  
  379. yMin = 999
  380.  
  381. end
  382.  
  383.  
  384.  
  385. digQuarry(-80, 284, 85)
  386. goto(xHome, zHome, yHome)
  387.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement