View difference between Paste ID: kLCYzMW6 and dgAdW8pn
SHOW: | | - or go back to the newest paste.
1
--Created by: pastebin.com/u/Gamboodle
2
--Edited by:  pastebin.com/u/AlexanderHaffer
3-
--Version:    1.2.4 e2
3+
--Version:    1.2.4 e1
4-
4+
5
term.clear()
6
term.setCursorPos(1,1)
7-
print("Please ensure that the turtle has enough fuel!")
7+
8-
print("Current fuel level: " .. turtle.getFuelLevel())
8+
9-
print("Maximum fuel levels are 20k for a regular and 100k for a mining turtle.")
9+
10-
sleep(5)
10+
11
io.write("Rows forward: ")
12
rows = io.read()
13
io.write("Columns sideways: ")
14
columns = io.read()
15
iniY = 2
16
if quarrybore == "quarry" then
17-
io.write("Blocks forward: ")
17+
18
    term.setCursorPos(1,1)
19-
io.write("Blocks sideways: ")
19+
20
    iniY = io.read()
21
end
22-
limitY = 5
22+
23
term.setCursorPos(1,1)
24
io.write("Toss garbage blocks like Cobblestone?")
25
io.write("Select 'yes' or 'no': ")
26
tossGarbage = io.read()
27
term.clear()
28
term.setCursorPos(1,1)
29
 
30-
    io.write("Lowest 'y' level: ")
30+
31-
    limitY = io.read()
31+
32
posZ = 0
33
 
34
rotation = 0
35
 
36
fullSlots = 0
37
 
38
function info()
39
    term.clear()
40
    term.setCursorPos(1,1)
41
    print("---------------------------------------")
42
    print("Mining size: " .. rows .. " by " .. columns)
43
--  print("Total distance: " .. posX + posY + posZ)
44
    print("X: " .. posX)
45
    print("Y: " .. posY)
46
    print("Z: " .. posZ)
47
    print("Orientation: " .. rotation)
48
    if tossGarbage == "yes" then
49
        print("Tossing garbage.")
50
    else
51
        print("Keeping garbage.")
52
    end
53
    print("")
54-
    print("Mining down to level " .. limitY)
54+
55
end
56-
--  print("X: " .. posX)
56+
57-
--  print("Y: " .. posY)
57+
58-
--  print("Z: " .. posZ)
58+
59-
--  print("Orientation: " .. rotation)
59+
60
    elseif rotation == 1 then
61
        turtle.turnLeft()
62
        turtle.turnLeft()
63
    elseif rotation == 2 then
64
        turtle.turnRight()
65
    end
66
end
67
 
68
function recover()
69
    rotate()
70
    local step = 0
71
    for step = posY - 1, 0, -1 do
72
        turtle.up()
73
    end
74
    for step = posX - 1, 0, -1 do
75
        turtle.forward()
76
    end
77
    turtle.turnLeft()
78
    for step = posZ - 1, 0, -1 do
79
        turtle.forward()
80
    end
81
end
82
 
83
function resume()
84
    turtle.turnLeft()
85
    turtle.turnLeft()
86
    local step = 0
87
    for step = 0, posZ - 1, 1 do
88
        turtle.forward()
89
    end
90
    turtle.turnRight()
91
    for step = 0, posX - 1, 1 do
92
        turtle.forward()
93
    end
94
    for step = 0, posY - 1, 1 do
95
        turtle.down()
96
    end
97
    if rotation == 0 then
98
        turtle.turnLeft()
99
    elseif rotation == 2 then
100
        turtle.turnRight()
101
    elseif rotation == 3 then
102
        turtle.turnRight()
103
        turtle.turnRight()
104
    end
105
end
106
 
107
function checkFuel()
108
    turtle.select(1)
109
    turtle.refuel()
110
    if turtle.getFuelLevel() <= posX + posY + posZ + 1 then
111
        refill = 1
112
        empty()
113
        refill = 0
114
    end
115
end
116
 
117
function empty()
118
    recover()
119
    if quarrybore == "bore" then
120
        turtle.down()
121
    end 
122
    local search = 0
123
    for search = 16, 1, -1 do
124
        turtle.select(search)
125
        turtle.drop()
126
    end
127
    if refill == 1 then
128
        turtle.turnRight()
129
        while turtle.getFuelLevel() <= posX + posY + posZ + 1 do
130
            if turtle.suck() == true then
131
                turtle.suck()
132
                turtle.select(1)
133
                turtle.refuel()
134
            elseif turtle.suck() == false then
135
                turtle.select(1)
136
                turtle.refuel()
137
                term.clear()
138
                term.setCursorPos(1,1)
139
                io.write("Please add more fuel to slot '1' or fuel chest.")
140
            end
141
        end
142
        turtle.turnLeft()
143
        resume()
144
    end
145
    if done ~= 1 then
146
        if quarrybore == "bore" then
147
            turtle.up()
148
        end 
149
        resume()
150
    end
151-
                io.write("Please add fuel to slot '1' or fuel chest.")
151+
152
 
153
function checkFull()
154
    fullSlots = 0
155
    local search = 0
156
    for search = 16, 1, -1 do
157
        turtle.select(search)
158
        if turtle.getItemCount() > 0 then
159
            if tossGarbage == "yes" then
160
                if turtle.getItemDetail().name == "minecraft:cobblestone" then
161
                    turtle.drop()
162
                elseif turtle.getItemDetail().name == "minecraft:stone" then
163
                    turtle.drop()
164
                elseif turtle.getItemDetail().name == "minecraft:dirt" then
165
                    turtle.drop()
166
                elseif turtle.getItemDetail().name == "minecraft:gravel" then
167
                    turtle.drop()
168
                elseif turtle.getItemDetail().name == "chisel:marble2" then
169
                    turtle.drop()
170
                elseif turtle.getItemDetail().name == "chisel:limestone2" then
171
                    turtle.drop()
172
                elseif turtle.getItemDetail().name == "minecraft:netherrack" then
173
                    turtle.drop()
174
                elseif turtle.getItemDetail().name == "natura:nether_tainted_soil" then
175
                    turtle.drop()
176
                end
177
            end
178
        end
179
        if turtle.getItemCount() > 0 then
180
            fullSlots = fullSlots + 1
181
        end
182
    end
183
    if fullSlots == 16 then
184
        empty()
185
    end
186
end
187
 
188
function nextRow()
189
    if turn == 0 then
190
        turtle.turnRight()
191
        rotation = 1
192
        digStraight()
193
        turtle.turnRight()
194
        rotation = 2
195
        turn = 1
196
    elseif turn == 1 then
197
        turtle.turnLeft()
198
        rotation = 1
199
        digStraight()
200
        turtle.turnLeft()
201
        rotation = 0
202
        turn = 0 
203
    elseif turn == 2 then
204
        turtle.turnRight()
205
        rotation = 3
206
        digStraight()
207
        turtle.turnRight()
208
        rotation = 0
209
        turn = 3
210
    elseif turn == 3 then
211
        turtle.turnLeft()
212
        rotation = 3
213
        digStraight()
214
        turtle.turnLeft()
215
        rotation = 2
216
        turn = 2
217
    end
218
end
219
 
220
function digDown()
221
    checkFuel()
222
    local step = 0
223
    for step = 2, 0, -1 do
224
        turtle.digDown()
225
        if turtle.down() == true then
226
            posY = posY + 1
227
        end
228
        info()
229
    end
230
end
231
 
232
function digStraight()
233
    checkFuel()
234
    turtle.digDown()
235
    turtle.dig()
236
    turtle.dig()
237
    turtle.forward()
238
    if rotation == 0 then
239
        posZ = posZ + 1
240
    elseif rotation == 1 then
241
        posX = posX + 1
242
    elseif rotation == 2 then
243
        posZ = posZ - 1
244
    elseif rotation == 3 then
245
        posX = posX - 1
246
    end
247
    turtle.digUp()
248
    info()
249
end
250
 
251
function quarry()
252
    turn = 0
253
    done = 0
254
    iniY = tonumber (iniY)
255
    checkFuel()
256
    turtle.digUp()
257
    turtle.up()
258
    posY = posY - 1
259
    while posY < iniY - 2 do
260
        if quarrybore == "quarry" then
261
            digDown()
262
        end
263
        for c = columns, 1, -1 do
264
            for r = rows, 2, -1 do
265
                digStraight()
266
            end
267-
    limitY = tonumber (limitY)
267+
268
            if c == 1 then
269
                turtle.turnRight()
270
                turtle.turnRight()
271
                if rotation == 0 then
272
                    rotation = 2
273
                elseif rotation == 2 then
274
                    rotation = 0
275
                end
276
                if turn == 0 then
277
                    turn = 2
278
                elseif turn == 1 then
279
                    turn = 3
280
                elseif turn == 2 then
281
                    turn = 0
282
                elseif turn == 3 then
283
                    turn = 1
284
                end
285
            elseif c > 1 then
286
                nextRow()
287
            end
288
        end
289
        if quarrybore == "bore" then
290
            posY = posY + 1
291
        end
292
    end
293
    turtle.digDown()
294
    done = 1
295
    empty()
296
    term.clear()
297
    term.setCursorPos(1,1)
298
    print("Done!")
299
    print("---------------------------------------")
300
end
301
 
302
quarry()