# Quarry.lua

Jun 17th, 2021 (edited)
721
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. partnerID = 0
2. turtle.refuel(1)
3.
4. function mine()
5.     turtle.dig()
6.     turtle.digUp()
7.     turtle.forward()
8. end
9.
10. function turnLeft()
11.     turtle.turnLeft()
12.     mine()
13.     turtle.turnLeft()
14. end
15.
16. function turnRight()
17.     turtle.turnRight()
18.     mine()
19.     turtle.turnRight()
20. end
21.
22. print("How wide?")
24. print("How long?")
26. print("How many layers?")
28.
29. function mineWidth()
30.     for i = width-1,1,-1 do
31.     mine()
32.     rednet.send(partnerID,"Forward")
33.     end
34. end
35.
36. turnCount = 1
37. function mineTotal()
38.     for i = length,1,-1 do
39.         mineWidth()
40.         if i ~= 1 then
41.             if turnCount == 1 then
42.                 turnLeft()
43.                 rednet.send(partnerID,"turnLeft")
44.                 turnCount = turnCount + 1
45.             elseif turnCount == 2 then
46.                 turnRight()
47.                 rednet.send(partnerID,"turnRight")
48.                 turnCount = turnCount - 1
49.             end
50.         end
51.     end
52. end
53.
54. function mineFull()
55.     turtle.digDown()
56.     turtle.down()
57.     rednet.send(partnerID,"Down")
58.     mineTotal()
59.     turtle.turnLeft()
60.     turtle.turnLeft()
61.     rednet.send(partnerID,"Turn Around")
62. end
63.
64. function ivFull()
65.     for i = 1,16 do
66.         if turtle.getItemCount(i) == 0 then
67.             return false
68.         end
69.     end
70.     return true
71. end
72.
73. function layerCount()
74.     for i=layers,1,-1 do
75.         if ivFull() == false then
76.             mineFull()
77.         else
78.             turtle.turnLeft()
79.             turtle.dig()
80.             turtle.place()
81.             for i = 2,16 do
82.                 turtle.select(i)
83.                 turtle.drop()
84.             end
85.             turtle.turnRight()
86.             turtle.select(1)
87.         end
88.         select(1)
89.         if turtle.getItemCount(1) == 0 then
90.             break
91.         end
92.     end
93.     for i=layers,1,-1 do
94.         rednet.send(partnerID,"Up")
95.         turtle.up()
96.     end
97. end
98.
99. rednet.open("left")