﻿

# quarry

a guest
Dec 8th, 2019
104
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. miningPlot = {0,0,0}
2. -- NO NEGATIVES PLEASE ^ USE BOX FUNCTIOn
3.
4. pos = {0,0,0}
5. -- +for/back- , -left/Right+ , +Up/Down-
6.
7. --Preconditon: chest behind area to min in front
8.
9.
10. direction = 0
11. -- 0 = ^ , 1 = > , 2 = v , 3 = <,4 = up ,5 down
12. function increment(dir)--dir is where going
13.     if dir == 0 then
14.         pos[1] = pos[1] + 1
15.     elseif dir == 1 then
16.         pos[2] = pos[2] + 1
17.
18.     elseif dir == 2 then
19.         pos[1] = pos[1] - 1
20.     elseif dir == 3 then
21.         pos[2] = pos[2] - 1
22.
23.     elseif dir == 4 then
24.         pos[3] = pos[3] + 1
25.     elseif dir == 5 then
26.         pos[3] = pos[3] - 1
27.
28.     end
29.
30.     --print(pos[1].." "..pos[2].." "..pos[3])
31. end
32.
33. function left(x)
34.     turtle.turnLeft()
35.     forward(x)
36.     turtle.turnRight()
37.     for y=1, x do
38.         increment(3)
39.     end
40. end
41.
42. function right(x)
43.     turtle.turnRight()
44.     forward(x)
45.     turtle.turnLeft()
46.     for y=1,x do
47.         increment(1)
48.     end
49. end
50.
51. function back(z)
52.     turtle.turnLeft()
53.     turtle.turnLeft()
54.
55.     forward(z)
56.
57.     turtle.turnRight()
58.     turtle.turnRight()
59.     for x=1, z do
60.         increment(2)
61.     end
62. end
63.
64. function forward(dis,real)
65.     real = real or false
66.
67.     for i=1, dis do
68.         turtle.dig()
69.         turtle.suck()
70.         turtle.forward()
71.         if real then
72.             increment(0)
73.         end
74.     end
75. end
76.
77. function up(dis)
78.     dis = dis or 1
79.     for x=1, dis do
80.         turtle.digUp()
81.         turtle.suckUp()
82.         turtle.up()
83.         increment(4)
84.     end
85. end
86.
87. function down(dis)
88.     dis= dis or 1
89.     for x=1, dis do
90.         turtle.digDown()
91.         turtle.suckDown()
92.         turtle.down()
93.         increment(5)
94.     end
95. end
96. --precondition: turtle within left lowest corner facing towards to be mined space
97. --postcondition: back in positon & direction
98. function plane()
99.     for x=1, miningPlot[1] + 1 do
100.         if x%2 ~= 0 then
101.             forward(miningPlot[1],true)
102.         else
103.             back(miningPlot[1])
104.         end
105.         if pos[1] ~= miningPlot[1] or pos[2] ~= miningPlot[2] then
106.             right(1)
107.         end
108.     end
109.     returnToOrigin(false)
110. end
111.
112.     --going back to positon
113.
114. function returnToOrigin(doY)
115.     if doY ~= nil or doY == false then
116.         doY= false
117.     else
118.         doY = true
119.     end
120.     if pos[1] >0 then
121.         back(pos[1])
122.     end
123.     if pos[2] > 0 then
124.         left(pos[2])
125.     end
126.     if doY and pos[3] > 0 then
127.         down(pos[3])
128.     end
129. end
130.
131. --Carves out a box CORNER to CORNER
132. --WARNING gravel & water not yet supported
133. --x,y,z are points of corner, other corner is Turtle
134. function box(x,y,z)
135.     miningPlot[1]= x or 7
136.     miningPlot[2]= z or 7
137.     miningPlot[3]= y or 4
138.     for i=0 ,miningPlot[3] do
139.         plane()
140.         if i ~= miningPlot[3] then
141.             up(1)
142.         end
143.     end
144.     returnToOrigin()
145. end
146.
147. box(2,2,3)
RAW Paste Data