-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathturtle.quarry.lua
More file actions
175 lines (148 loc) · 2.81 KB
/
turtle.quarry.lua
File metadata and controls
175 lines (148 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
-- Args
ARGS = {...}
length = ARGS[1]
width = ARGS[2]
depth = ARGS[3]
x=0
y=0
z=0
if width-1<1 or length-1<1 or depth-1<0 then
print("The argument is too low!")
os.queueEvent("terminate")
sleep(1)
end
-- Moving
function moving()
for j=1,width do
for i=1,length-1 do
turtle.dig()
turtle.forward()
if j%2==0 then
x=x-1
else
x=x+1
end
print("Now on: ", x, ",", y, ",", z)
end
if y~=(width-1) then
if j%2==0 then
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.turnLeft()
else
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.turnRight()
end
y=y+1
end
print("Now on: ", x, ",", y, ",", z)
end
if y%2==0 then
turtle.turnLeft()
else
turtle.turnRight()
end
for i=1, width-1 do
turtle.forward()
y=y-1
print("Now on: ", x, ",", y, ",", z)
end
if x==0 then
turtle.turnRight()
else
turtle.turnLeft()
for i=1, length-1 do
turtle.forward()
x=x-1
print("Now on: ", x, ",", y, ",", z)
end
turtle.turnRight()
turtle.turnRight()
end
end
function itemfull(z)
nowdepth=z
x_z=z
y=0
x=0
turtle.turnRight()
turtle.turnRight()
for i=1, nowdepth do
turtle.up()
x_z=x_z-1
print("Now on: ", x, ",", y, ",", x_z)
end
for i=1, 16 do
turtle.select(i)
turtle.drop(i)
end
for i=1, nowdepth do
turtle.down()
x_z=x_z+1
print("Now on: ", x, ",", y, ",", x_z)
end
turtle.turnRight()
turtle.turnRight()
turtle.select(1)
end
function fuelerror(z)
turtle.turnRight()
turtle.turnRight()
for i=1, z do
turtle.up()
end
turtle.turnRight()
turtle.turnRight()
print("The fuel is too low!")
os.queueEvent("terminate")
sleep(1)
end
----------------------------
-- Mining
turtle.select(1)
print("Range: ", length, " x ", width, " x ", depth)
print("Minning start")
sleep(1)
print("Now on: ", x, ",", y, ",", z)
turtle.digDown()
turtle.down()
z=z+1
print("Now on: ", x, ",", y, ",", z)
for i=1, depth do
moving()
if turtle.getItemCount(15)>0 then
itemfull(z)
end
if turtle.getFuelLevel()<40+depth then
fuelerror(z)
end
if i-1~=depth-1 then
turtle.digDown()
turtle.down()
z=z+1
print("Now on: ", x, ",", y, ",", z)
end
end
--Elevation
turtle.turnRight()
turtle.turnRight()
for i=1, depth do
turtle.up()
end
-- Item
for i=1, 16 do
turtle.select(i)
turtle.drop()
end
turtle.select(1)
turtle.turnRight()
turtle.turnRight()
turtle.turnRight()
turtle.forward()
turtle.turnRight()
turtle.dig()
turtle.forward()
print("Mining has ended!")