SHOW:
|
|
- or go back to the newest paste.
1 | function serialize(data, name) -- this is for setting the variable "data" what you want and "name" is the file name. when saving a number to the file make sure to write as tonumber(read()) (this overwrites each time) | |
2 | if not fs.exists('/data') then | |
3 | fs.makeDir('/data') | |
4 | end | |
5 | local f = fs.open('/data/'..name, 'w') | |
6 | f.write(textutils.serialize(data)) | |
7 | f.close() | |
8 | end | |
9 | ||
10 | function unserialize(name) --this will bring up the file name in my program i need to make x = unserialize(name) this will set my variable to the saved number | |
11 | if fs.exists('/data/'..name) then | |
12 | local f = fs.open('/data/'..name, 'r') | |
13 | data = textutils.unserialize(f.readAll()) | |
14 | f.close() | |
15 | end | |
16 | return data | |
17 | end | |
18 | ||
19 | --this sets up a host computer for gps network (below text) | |
20 | --shell.run("gps","host",x,y,z) | |
21 | --then on the turtle side you can set x, y, z = gps.locate(1) the one is the time till it times out if it cant find position | |
22 | ||
23 | function recieve() --this is the recieve side to run scripts | |
24 | modem = peripheral.wrap("left") | |
25 | modem.open(0) | |
26 | while true do | |
27 | event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message") | |
28 | ||
29 | if message == "up" then | |
30 | turtle.up() | |
31 | end | |
32 | ||
33 | if message == "down" then | |
34 | turtle.down() | |
35 | end | |
36 | end | |
37 | end | |
38 | ||
39 | function getHeading() --gets heading and stores it in file = heading and variable is p (1 north is negative, 3 south is positive, 4 east is negative, and 2 west is positive ) | |
40 | loc1 = vector.new(gps.locate(2,false)) | |
41 | for i = 1,10 do | |
42 | if turtle.detect() == true then | |
43 | turtle.dig() | |
44 | else | |
45 | end | |
46 | end | |
47 | turtle.forward() | |
48 | loc2 = vector.new(gps.locate(2,false)) | |
49 | if loc2.z - loc1.z < 0 then | |
50 | p = 1 | |
51 | elseif loc2.x - loc1.x > 0 then | |
52 | p = 2 | |
53 | elseif loc2.z - loc1.z > 0 then | |
54 | p = 3 | |
55 | elseif loc2.x - loc1.x < 0 then | |
56 | p = 4 | |
57 | end | |
58 | serialize(p, "heading") | |
59 | end | |
60 | ||
61 | function dig() --dig and sleeps | |
62 | - | turtle.dig() |
62 | + | while turtle.dig() == true do |
63 | sleep(0.5) | |
64 | end | |
65 | end | |
66 | - | turtle.digUp() |
66 | + | |
67 | function digup() | |
68 | while turtle.digUp() == true do | |
69 | sleep(0.5) | |
70 | - | turtle.digDown() |
70 | + | |
71 | end | |
72 | ||
73 | function digdown() | |
74 | - | --[[ |
74 | + | while turtle.digDown() == true do |
75 | - | local success, infront = turtle.inspect() |
75 | + | sleep(0.5) |
76 | - | local success, above = turtle.inspectUp() |
76 | + | |
77 | - | local success, below = turtle.inspectDown() |
77 | + | |
78 | - | if infront.name == "minecraft:lava" or infront.name == "minecraft:flowing_lava" or above.name == "minecraft:flowing_lava" or above.name == "minecraft:lava" then |
78 | + | |
79 | - | if turtle.getItemCount(2) > 5 then |
79 | + | |
80 | - | turtle.select(2) |
80 | + | |
81 | - | turtle.place() |
81 | + | |
82 | turtle.dig() | |
83 | - | turtle.place() |
83 | + | |
84 | if heading == 1 then | |
85 | z_c_f = z_c_i - 1 | |
86 | - | turtle.place() |
86 | + | |
87 | elseif heading == 2 then | |
88 | - | turtle.placeUp() |
88 | + | |
89 | - | turtle.placeDown() |
89 | + | |
90 | elseif heading == 3 then | |
91 | - | turtle.forward() |
91 | + | |
92 | - | |
92 | + | |
93 | - | elseif turtle.getItemCount(3) > 5 then |
93 | + | |
94 | - | turtle.select(3) |
94 | + | |
95 | - | turtle.place() |
95 | + | |
96 | end | |
97 | - | turtle.place() |
97 | + | |
98 | serialize(z_c_f, "zfinal") | |
99 | end | |
100 | - | turtle.place() |
100 | + | |
101 | function right() --turns right and sleeps | |
102 | - | turtle.placeUp() |
102 | + | |
103 | - | turtle.placeDown() |
103 | + | |
104 | if heading <= 3 then | |
105 | - | turtle.forward() |
105 | + | |
106 | - | |
106 | + | |
107 | - | elseif turtle.getItemCount(4) > 5 then |
107 | + | |
108 | - | turtle.select(4) |
108 | + | |
109 | - | turtle.place() |
109 | + | |
110 | - | turtle.turnLeft() |
110 | + | |
111 | - | turtle.place() |
111 | + | |
112 | - | turtle.turnRight() |
112 | + | |
113 | - | turtle.turnRight() |
113 | + | |
114 | - | turtle.place() |
114 | + | |
115 | - | turtle.turnLeft() |
115 | + | |
116 | - | turtle.placeUp() |
116 | + | |
117 | - | turtle.placeDown() |
117 | + | |
118 | end | |
119 | - | turtle.forward() |
119 | + | |
120 | - | |
120 | + | |
121 | function down() --goes down and sleeps | |
122 | - | elseif below.name == "minecraft:lava" or below.name == "minecraft:flowing_lava" then |
122 | + | while turtle.down() == false do |
123 | - | if turtle.getItemCount(2) > 5 then |
123 | + | |
124 | - | turtle.select(2) |
124 | + | turtle.digDown() |
125 | - | turtle.placeDown() |
125 | + | |
126 | y_c_f = y_c_i - 1 | |
127 | - | turtle.forward() |
127 | + | |
128 | - | |
128 | + | |
129 | - | elseif turtle.getItemCount(3) > 5 then |
129 | + | |
130 | - | turtle.select(3) |
130 | + | |
131 | - | turtle.placeDown() |
131 | + | |
132 | while turtle.up() == false do | |
133 | - | turtle.forward() |
133 | + | |
134 | - | |
134 | + | turtle.digUp() |
135 | - | elseif turtle.getItemCount(4) > 5 then |
135 | + | |
136 | - | turtle.select(4) |
136 | + | |
137 | - | turtle.placeDown() |
137 | + | |
138 | serialize(y_c_f, "yfinal") | |
139 | - | turtle.forward() |
139 | + | |
140 | - | |
140 | + | |
141 | function inspect() | |
142 | turtle.inspect() | |
143 | - | --]] |
143 | + | |
144 | ||
145 | function detect() | |
146 | turtle.detect() | |
147 | end | |
148 | ||
149 | function clearinventory() | |
150 | for i = 2, 16 do | |
151 | turtle.select(i) | |
152 | turtle.dropUp() | |
153 | end | |
154 | turtle.select(1) | |
155 | end | |
156 | ||
157 | function backtostart() | |
158 | ||
159 | x_c_f = x_c_f - x_i | |
160 | y_c_f = y_c_f - y_i | |
161 | z_c_f = z_c_f - z_i | |
162 | ||
163 | print(x_c_f) | |
164 | print(y_c_f) | |
165 | print(z_c_f) | |
166 | ||
167 | ||
168 | if x_c_f == 0 then | |
169 | movex = 0 | |
170 | else | |
171 | movex = x_c_f - x_i | |
172 | end | |
173 | if y_c_f == 0 then | |
174 | movey = 0 | |
175 | else | |
176 | movey = y_c_f - y_i | |
177 | end | |
178 | if z_c_f == 0 then | |
179 | movez = 0 | |
180 | else | |
181 | movez = z_c_f - z_i | |
182 | end | |
183 | ||
184 | --move the turtle to correct y position | |
185 | if movey > 0 then | |
186 | - | turtle.down() |
186 | + | |
187 | while digdown() == true do | |
188 | digdown() | |
189 | end | |
190 | down() | |
191 | end | |
192 | else | |
193 | - | turtle.up() |
193 | + | |
194 | while digup() == true do | |
195 | digup() | |
196 | end | |
197 | up() | |
198 | end | |
199 | end | |
200 | --move the turtle to correct x position | |
201 | if movex > 0 then | |
202 | if heading == 1 then | |
203 | left() | |
204 | for i = 1, movex do | |
205 | while dig() == true do | |
206 | dig() | |
207 | end | |
208 | - | for i = 5, 16 do |
208 | + | |
209 | end | |
210 | elseif heading == 2 then | |
211 | right() | |
212 | - | turtle.select(5) |
212 | + | |
213 | for i = 1, movex do | |
214 | while dig() == true do | |
215 | dig() | |
216 | end | |
217 | forward() | |
218 | end | |
219 | elseif heading == 3 then | |
220 | right() | |
221 | for i = 1, movex do | |
222 | while dig() == true do | |
223 | dig() | |
224 | end | |
225 | forward() | |
226 | end | |
227 | elseif heading == 4 then | |
228 | for i = 1, movex do | |
229 | while dig() == true do | |
230 | dig() | |
231 | end | |
232 | forward() | |
233 | end | |
234 | end | |
235 | elseif movex == 0 then | |
236 | elseif movex < 0 then | |
237 | if heading == 1 then | |
238 | right() | |
239 | for i = -1, movex, -1 do | |
240 | while dig() == true do | |
241 | dig() | |
242 | end | |
243 | forward() | |
244 | end | |
245 | elseif heading == 2 then | |
246 | for i = -1, movex, -1 do | |
247 | while dig() == true do | |
248 | dig() | |
249 | end | |
250 | forward() | |
251 | end | |
252 | elseif heading == 3 then | |
253 | left() | |
254 | for i = -1, movex, -1 do | |
255 | while dig() == true do | |
256 | dig() | |
257 | end | |
258 | forward() | |
259 | end | |
260 | elseif heading == 4 then | |
261 | right() | |
262 | right() | |
263 | for i = -1, movex, -1 do | |
264 | while dig() == true do | |
265 | dig() | |
266 | end | |
267 | forward() | |
268 | end | |
269 | end | |
270 | ||
271 | end | |
272 | --move turtle to correct z position | |
273 | if movez < 0 then | |
274 | if heading == 1 then | |
275 | right() | |
276 | right() | |
277 | for i = -1, movez, -1 do | |
278 | while dig() == true do | |
279 | dig() | |
280 | end | |
281 | forward() | |
282 | end | |
283 | elseif heading == 2 then | |
284 | right() | |
285 | for i = -1, movez, -1 do | |
286 | while dig() == true do | |
287 | dig() | |
288 | end | |
289 | forward() | |
290 | end | |
291 | elseif heading == 3 then | |
292 | for i = -1, movez, -1 do | |
293 | while dig() == true do | |
294 | dig() | |
295 | end | |
296 | forward() | |
297 | end | |
298 | elseif heading == 4 then | |
299 | left() | |
300 | for i = -1, movez, -1 do | |
301 | while dig() == true do | |
302 | dig() | |
303 | end | |
304 | forward() | |
305 | end | |
306 | end | |
307 | elseif movez == 0 then | |
308 | elseif movez > 0 then | |
309 | if heading == 1 then | |
310 | for i = 1, movez do | |
311 | while dig() == true do | |
312 | dig() | |
313 | end | |
314 | forward() | |
315 | end | |
316 | elseif heading == 2 then | |
317 | left() | |
318 | for i = 1, movez do | |
319 | while dig() == true do | |
320 | dig() | |
321 | end | |
322 | forward() | |
323 | end | |
324 | elseif heading == 3 then | |
325 | right() | |
326 | right() | |
327 | for i = 1, movez do | |
328 | while dig() == true do | |
329 | dig() | |
330 | end | |
331 | forward() | |
332 | end | |
333 | elseif heading == 4 then | |
334 | right() | |
335 | for i = 1, movez do | |
336 | while dig() == true do | |
337 | dig() | |
338 | end | |
339 | forward() | |
340 | end | |
341 | end | |
342 | end | |
343 | end | |
344 | ||
345 | function returntowork() | |
346 | x_c_f = unserialize("xreturn") | |
347 | y_c_f = unserialize("yreturn") | |
348 | z_c_f = unserialize("zreturn") | |
349 | ||
350 | x_c_f = x_c_f*1 | |
351 | y_c_f = y_c_f*1 | |
352 | z_c_f = z_c_f*1 | |
353 | ||
354 | if x_c_f == 0 then | |
355 | movex = 0 | |
356 | else | |
357 | movex = x_c_f - x_i | |
358 | end | |
359 | if y_c_f == 0 then | |
360 | movey = 0 | |
361 | else | |
362 | movey = y_c_f - y_i | |
363 | end | |
364 | if z_c_f == 0 then | |
365 | movez = 0 | |
366 | else | |
367 | movez = z_c_f - z_i | |
368 | end | |
369 | ||
370 | --move turtle to correct z position | |
371 | if movez < 0 then | |
372 | if heading == 1 then | |
373 | for i = -1, movez, -1 do | |
374 | while dig() == true do | |
375 | dig() | |
376 | end | |
377 | forward() | |
378 | end | |
379 | elseif heading == 2 then | |
380 | left() | |
381 | for i = -1, movez, -1 do | |
382 | while dig() == true do | |
383 | dig() | |
384 | end | |
385 | forward() | |
386 | end | |
387 | elseif heading == 3 then | |
388 | right() | |
389 | right() | |
390 | for i = -1, movez, -1 do | |
391 | while dig() == true do | |
392 | dig() | |
393 | end | |
394 | forward() | |
395 | end | |
396 | elseif heading == 4 then | |
397 | right() | |
398 | for i = -1, movez, -1 do | |
399 | while dig() == true do | |
400 | dig() | |
401 | end | |
402 | forward() | |
403 | end | |
404 | end | |
405 | elseif movez == 0 then | |
406 | elseif movez > 0 then | |
407 | if heading == 1 then | |
408 | right() | |
409 | right() | |
410 | for i = 1, movez do | |
411 | while dig() == true do | |
412 | dig() | |
413 | end | |
414 | forward() | |
415 | end | |
416 | elseif heading == 2 then | |
417 | right() | |
418 | for i = 1, movez do | |
419 | while dig() == true do | |
420 | dig() | |
421 | end | |
422 | forward() | |
423 | end | |
424 | elseif heading == 3 then | |
425 | for i = 1, movez do | |
426 | while dig() == true do | |
427 | dig() | |
428 | end | |
429 | forward() | |
430 | end | |
431 | elseif heading == 4 then | |
432 | left() | |
433 | for i = 1, movez do | |
434 | while dig() == true do | |
435 | dig() | |
436 | end | |
437 | forward() | |
438 | end | |
439 | end | |
440 | end | |
441 | --move the turtle to correct x position | |
442 | if movex > 0 then | |
443 | if heading == 1 then | |
444 | right() | |
445 | for i = 1, movex do | |
446 | while dig() == true do | |
447 | dig() | |
448 | end | |
449 | forward() | |
450 | end | |
451 | elseif heading == 2 then | |
452 | for i = 1, movex do | |
453 | while dig() == true do | |
454 | dig() | |
455 | end | |
456 | forward() | |
457 | end | |
458 | elseif heading == 3 then | |
459 | left() | |
460 | for i = 1, movex do | |
461 | while dig() == true do | |
462 | dig() | |
463 | end | |
464 | forward() | |
465 | end | |
466 | elseif heading == 4 then | |
467 | right() | |
468 | right() | |
469 | for i = 1, movex do | |
470 | while dig() == true do | |
471 | dig() | |
472 | end | |
473 | forward() | |
474 | end | |
475 | end | |
476 | elseif movex == 0 then | |
477 | elseif movex < 0 then | |
478 | if heading == 1 then | |
479 | left() | |
480 | for i = -1, movex, -1 do | |
481 | while dig() == true do | |
482 | dig() | |
483 | end | |
484 | forward() | |
485 | end | |
486 | elseif heading == 2 then | |
487 | right() | |
488 | right() | |
489 | for i = -1, movex, -1 do | |
490 | while dig() == true do | |
491 | dig() | |
492 | end | |
493 | forward() | |
494 | end | |
495 | elseif heading == 3 then | |
496 | right() | |
497 | for i = -1, movex, -1 do | |
498 | while dig() == true do | |
499 | dig() | |
500 | end | |
501 | forward() | |
502 | end | |
503 | elseif heading == 4 then | |
504 | for i = -1, movex, -1 do | |
505 | while dig() == true do | |
506 | dig() | |
507 | end | |
508 | forward() | |
509 | end | |
510 | end | |
511 | ||
512 | end | |
513 | --move the turtle to correct y position | |
514 | if movey > 0 then | |
515 | for i = 1, movey do | |
516 | while digup() == true do | |
517 | digup() | |
518 | end | |
519 | up() | |
520 | end | |
521 | else | |
522 | for i = -1, movey, -1 do | |
523 | while digdown() == true do | |
524 | digdown() | |
525 | end | |
526 | down() | |
527 | end | |
528 | end | |
529 | ||
530 | headingreturn = tonumber(unserialize("headingreturn")) | |
531 | while heading ~= headingreturn do | |
532 | right() | |
533 | end | |
534 | end | |
535 | ||
536 | function inventorycheck() | |
537 | if turtle.getItemCount(16) > 0 then | |
538 | - | for i = -1, movex do |
538 | + | |
539 | serialize(y_c_f, "yreturn") | |
540 | serialize(z_c_f, "zreturn") | |
541 | serialize(heading, "headingreturn") | |
542 | backtostart() | |
543 | clearinventory() | |
544 | returntowork() | |
545 | else | |
546 | end | |
547 | - | for i = -1, movex do |
547 | + | |
548 | ||
549 | function refuel() | |
550 | if turtle.getItemCount(1) == 0 or turtle.getItemDetail(1).name ~= "minecraft:coal" and turtle.getItemDetail(1).name ~= "actuallyadditions:block_misc") then | |
551 | backtostart() | |
552 | print("Waiting for fuel to be placed in slot 1.") | |
553 | while turtle.getItemCount(1) == 0 or turtle.getItemDetail(1).name ~= "minecraft:coal" do | |
554 | sleep(1) | |
555 | - | for i = -1, movex do |
555 | + | |
556 | while turtle.getFuelLevel() < 1000 do | |
557 | turtle.select(1) | |
558 | turtle.refuel(1) | |
559 | end | |
560 | returntowork() | |
561 | elseif turtle.getItemCount(1) > 0 then | |
562 | - | for i = -1, movex do |
562 | + | while turtle.getFuelLevel() < 19900 do |
563 | turtle.select(1) | |
564 | turtle.refuel(1) | |
565 | sleep(1) | |
566 | end | |
567 | end | |
568 | end | |
569 | ||
570 | function digcubebottomleft() --efficiently mines out an area determined by the user | |
571 | print("Place coal blocks or coal in slot 1. Also dig a pit trap 2 blocks in front of the turtle in case a mob spawns in front of it. (optional but could slightly speed up process)") | |
572 | ||
573 | print("What is the width? this number expands to the right with the first part of the cube being in front of the turtle.") | |
574 | w = tonumber(read()) | |
575 | ||
576 | print("What is the length? This number expands into the area you are excavating.") | |
577 | l = tonumber(read()) | |
578 | ||
579 | print("What is the height? This number is the how many blocks up the cube expands up from starting position") | |
580 | h = tonumber(read()) | |
581 | ||
582 | print("what is the current direction the turtle is facing? (type 1 for north, 2 for east, 3 for south and 4 for west)") | |
583 | heading = tonumber(read()) | |
584 | ||
585 | while dig() == true do --this get the turtle into position | |
586 | dig() | |
587 | end | |
588 | forward() | |
589 | if l > w and l > h then --if the cube has a long length like a tunnel this will be the function it follows | |
590 | for a = 1, h do | |
591 | for b = 1, w do --this digs into the cube | |
592 | for c = 1, (l-1) do --this digs the length | |
593 | while dig() == true do | |
594 | dig() | |
595 | end | |
596 | forward() | |
597 | end | |
598 | if w%2 == 1 then | |
599 | if b < w then | |
600 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
601 | right() | |
602 | inventorycheck() | |
603 | refuel() | |
604 | while dig() == true do | |
605 | dig() | |
606 | end | |
607 | forward() | |
608 | - | if turtle.getItemCount(1) == 0 then |
608 | + | |
609 | else | |
610 | left() | |
611 | - | while turtle.getItemCount == 0 do |
611 | + | inventorycheck() |
612 | refuel() | |
613 | while dig() == true do | |
614 | - | while turtle.getFuelLevel() <1000 do |
614 | + | |
615 | - | turtle.select(1) |
615 | + | |
616 | - | turtle.refuel() |
616 | + | |
617 | left() | |
618 | end | |
619 | else | |
620 | - | while turtle.getFuelLevel() <1000 do |
620 | + | |
621 | else -- this is the nightmare scenario where the width is even causing the turns to be different from layer to layer | |
622 | - | turtle.refuel() |
622 | + | |
623 | if a%2 == 1 then | |
624 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
625 | right() | |
626 | inventorycheck() | |
627 | refuel() | |
628 | - | print("Place coal blocks or coal in slot 1. Also place a stack of cobblestone in slots 2, 3, 4. Also dig a pit trap 2 blocks in front of the turtle in case a mob spawns in front of it.") |
628 | + | |
629 | dig() | |
630 | end | |
631 | forward() | |
632 | right() | |
633 | else | |
634 | left() | |
635 | inventorycheck() | |
636 | refuel() | |
637 | while dig() == true do | |
638 | dig() | |
639 | end | |
640 | forward() | |
641 | left() | |
642 | end | |
643 | else | |
644 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
645 | left() | |
646 | inventorycheck() | |
647 | refuel() | |
648 | while dig() == true do | |
649 | dig() | |
650 | end | |
651 | forward() | |
652 | left() | |
653 | else | |
654 | right() | |
655 | inventorycheck() | |
656 | refuel() | |
657 | while dig() == true do | |
658 | dig() | |
659 | end | |
660 | forward() | |
661 | right() | |
662 | end | |
663 | end | |
664 | else | |
665 | end | |
666 | end | |
667 | end | |
668 | if a < h then | |
669 | while digup() == true do --this is to go up to next layer | |
670 | digup() | |
671 | end | |
672 | up() | |
673 | right() | |
674 | right() | |
675 | else | |
676 | end | |
677 | end | |
678 | elseif w > l and w > h then -- this is when the width is greater than the length and height | |
679 | for d = 1 , l-1 do | |
680 | while dig() == true do | |
681 | dig() | |
682 | end | |
683 | forward() | |
684 | end | |
685 | right() | |
686 | for a = 1, h do | |
687 | for b = 1, l do --this digs into the cube | |
688 | for c = 1, (w-1) do --this digs the length | |
689 | while dig() == true do | |
690 | dig() | |
691 | end | |
692 | forward() | |
693 | end | |
694 | if w%2 == 1 then | |
695 | if b < l then | |
696 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
697 | right() | |
698 | inventorycheck() | |
699 | refuel() | |
700 | while dig() == true do | |
701 | dig() | |
702 | end | |
703 | forward() | |
704 | right() | |
705 | else | |
706 | left() | |
707 | inventorycheck() | |
708 | refuel() | |
709 | while dig() == true do | |
710 | dig() | |
711 | end | |
712 | forward() | |
713 | left() | |
714 | end | |
715 | else | |
716 | end | |
717 | else -- this is the nightmare scenario where the width is even causing the turns to be different from layer to layer | |
718 | if b < l then | |
719 | if a%2 == 1 then | |
720 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
721 | right() | |
722 | inventorycheck() | |
723 | refuel() | |
724 | while dig() == true do | |
725 | dig() | |
726 | end | |
727 | forward() | |
728 | right() | |
729 | else | |
730 | left() | |
731 | inventorycheck() | |
732 | refuel() | |
733 | while dig() == true do | |
734 | dig() | |
735 | end | |
736 | forward() | |
737 | left() | |
738 | end | |
739 | else | |
740 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
741 | left() | |
742 | inventorycheck() | |
743 | refuel() | |
744 | while dig() == true do | |
745 | dig() | |
746 | end | |
747 | forward() | |
748 | left() | |
749 | else | |
750 | right() | |
751 | inventorycheck() | |
752 | refuel() | |
753 | while dig() == true do | |
754 | dig() | |
755 | end | |
756 | forward() | |
757 | right() | |
758 | end | |
759 | end | |
760 | else | |
761 | end | |
762 | end | |
763 | end | |
764 | if a < h then | |
765 | while digup() == true do --this is to go up to next layer | |
766 | digup() | |
767 | end | |
768 | up() | |
769 | right() | |
770 | right() | |
771 | else | |
772 | end | |
773 | end | |
774 | elseif h > w and h > l then | |
775 | for a = 1, w do | |
776 | for b = 1, l do --this digs into the cube | |
777 | for c = 1, (h-1) do --this digs the length | |
778 | if l%2 == 1 then | |
779 | if a%2 == 1 then | |
780 | if b%2 == 1 then | |
781 | while digup() == true do | |
782 | digup() | |
783 | end | |
784 | up() | |
785 | else | |
786 | while digdown() == true do | |
787 | digdown() | |
788 | end | |
789 | down() | |
790 | end | |
791 | else | |
792 | if b%2 == 1 then | |
793 | while digdown() == true do | |
794 | digdown() | |
795 | end | |
796 | down() | |
797 | else | |
798 | while digup() == true do | |
799 | digup() | |
800 | end | |
801 | up() | |
802 | end | |
803 | ||
804 | end | |
805 | else | |
806 | if b%2 == 1 then | |
807 | while digup() == true do | |
808 | digup() | |
809 | end | |
810 | up() | |
811 | else | |
812 | while digdown() == true do | |
813 | digdown() | |
814 | end | |
815 | down() | |
816 | end | |
817 | end | |
818 | end | |
819 | if b < l then | |
820 | while dig() == true do | |
821 | dig() | |
822 | end | |
823 | forward() | |
824 | inventorycheck() | |
825 | refuel() | |
826 | else | |
827 | end | |
828 | end | |
829 | if a < w then | |
830 | if a%2 == 1 then | |
831 | right() | |
832 | inventorycheck() | |
833 | refuel() | |
834 | while dig() == true do | |
835 | dig() | |
836 | end | |
837 | forward() | |
838 | right() | |
839 | else | |
840 | left() | |
841 | inventorycheck() | |
842 | refuel() | |
843 | while dig() == true do | |
844 | dig() | |
845 | end | |
846 | forward() | |
847 | left() | |
848 | end | |
849 | else | |
850 | end | |
851 | end | |
852 | elseif w == l then | |
853 | for a = 1, h do | |
854 | for b = 1, w do --this digs into the cube | |
855 | for c = 1, (l-1) do --this digs the length | |
856 | while dig() == true do | |
857 | dig() | |
858 | end | |
859 | forward() | |
860 | end | |
861 | if w%2 == 1 then | |
862 | if b < w then | |
863 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
864 | right() | |
865 | inventorycheck() | |
866 | refuel() | |
867 | while dig() == true do | |
868 | dig() | |
869 | end | |
870 | forward() | |
871 | right() | |
872 | else | |
873 | left() | |
874 | inventorycheck() | |
875 | refuel() | |
876 | while dig() == true do | |
877 | dig() | |
878 | end | |
879 | forward() | |
880 | left() | |
881 | end | |
882 | else | |
883 | end | |
884 | else -- this is the nightmare scenario where the width is even causing the turns to be different from layer to layer | |
885 | if b < w then | |
886 | if a%2 == 1 then | |
887 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
888 | right() | |
889 | inventorycheck() | |
890 | refuel() | |
891 | while dig() == true do | |
892 | dig() | |
893 | end | |
894 | forward() | |
895 | right() | |
896 | else | |
897 | left() | |
898 | inventorycheck() | |
899 | refuel() | |
900 | while dig() == true do | |
901 | dig() | |
902 | end | |
903 | forward() | |
904 | left() | |
905 | end | |
906 | else | |
907 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
908 | left() | |
909 | inventorycheck() | |
910 | refuel() | |
911 | while dig() == true do | |
912 | dig() | |
913 | end | |
914 | forward() | |
915 | left() | |
916 | else | |
917 | right() | |
918 | inventorycheck() | |
919 | refuel() | |
920 | while dig() == true do | |
921 | dig() | |
922 | end | |
923 | forward() | |
924 | right() | |
925 | end | |
926 | end | |
927 | else | |
928 | end | |
929 | end | |
930 | end | |
931 | if a < h then | |
932 | while digup() == true do --this is to go up to next layer | |
933 | digup() | |
934 | end | |
935 | up() | |
936 | right() | |
937 | right() | |
938 | else | |
939 | end | |
940 | end | |
941 | elseif w == h then | |
942 | for d = 1 , l-1 do | |
943 | while dig() == true do | |
944 | dig() | |
945 | end | |
946 | forward() | |
947 | end | |
948 | right() | |
949 | for a = 1, h do | |
950 | for b = 1, l do --this digs into the cube | |
951 | for c = 1, (w-1) do --this digs the length | |
952 | while dig() == true do | |
953 | dig() | |
954 | end | |
955 | forward() | |
956 | end | |
957 | if w%2 == 1 then | |
958 | if b < l then | |
959 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
960 | right() | |
961 | inventorycheck() | |
962 | refuel() | |
963 | while dig() == true do | |
964 | dig() | |
965 | end | |
966 | forward() | |
967 | right() | |
968 | else | |
969 | left() | |
970 | inventorycheck() | |
971 | refuel() | |
972 | while dig() == true do | |
973 | dig() | |
974 | end | |
975 | - | refuel() |
975 | + | |
976 | - | inventorycheck() |
976 | + | |
977 | end | |
978 | else | |
979 | end | |
980 | else -- this is the nightmare scenario where the width is even causing the turns to be different from layer to layer | |
981 | if b < l then | |
982 | if a%2 == 1 then | |
983 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
984 | - | refuel() |
984 | + | |
985 | - | inventorycheck() |
985 | + | |
986 | refuel() | |
987 | while dig() == true do | |
988 | dig() | |
989 | end | |
990 | forward() | |
991 | right() | |
992 | else | |
993 | left() | |
994 | inventorycheck() | |
995 | refuel() | |
996 | while dig() == true do | |
997 | dig() | |
998 | end | |
999 | forward() | |
1000 | left() | |
1001 | end | |
1002 | else | |
1003 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1004 | left() | |
1005 | inventorycheck() | |
1006 | refuel() | |
1007 | while dig() == true do | |
1008 | dig() | |
1009 | end | |
1010 | forward() | |
1011 | left() | |
1012 | else | |
1013 | right() | |
1014 | inventorycheck() | |
1015 | refuel() | |
1016 | while dig() == true do | |
1017 | dig() | |
1018 | end | |
1019 | forward() | |
1020 | right() | |
1021 | end | |
1022 | end | |
1023 | else | |
1024 | end | |
1025 | end | |
1026 | end | |
1027 | if a < h then | |
1028 | while digup() == true do --this is to go up to next layer | |
1029 | digup() | |
1030 | end | |
1031 | up() | |
1032 | right() | |
1033 | right() | |
1034 | else | |
1035 | end | |
1036 | end | |
1037 | elseif h == l then | |
1038 | for a = 1, h do | |
1039 | for b = 1, w do --this digs into the cube | |
1040 | for c = 1, (l-1) do --this digs the length | |
1041 | while dig() == true do | |
1042 | dig() | |
1043 | end | |
1044 | forward() | |
1045 | end | |
1046 | if w%2 == 1 then | |
1047 | if b < w then | |
1048 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1049 | right() | |
1050 | inventorycheck() | |
1051 | refuel() | |
1052 | while dig() == true do | |
1053 | dig() | |
1054 | end | |
1055 | forward() | |
1056 | right() | |
1057 | else | |
1058 | left() | |
1059 | inventorycheck() | |
1060 | refuel() | |
1061 | while dig() == true do | |
1062 | dig() | |
1063 | end | |
1064 | forward() | |
1065 | left() | |
1066 | end | |
1067 | else | |
1068 | end | |
1069 | else -- this is the nightmare scenario where the width is even causing the turns to be different from layer to layer | |
1070 | if b < w then | |
1071 | if a%2 == 1 then | |
1072 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1073 | right() | |
1074 | inventorycheck() | |
1075 | refuel() | |
1076 | while dig() == true do | |
1077 | dig() | |
1078 | end | |
1079 | forward() | |
1080 | right() | |
1081 | else | |
1082 | left() | |
1083 | inventorycheck() | |
1084 | refuel() | |
1085 | while dig() == true do | |
1086 | dig() | |
1087 | end | |
1088 | forward() | |
1089 | left() | |
1090 | end | |
1091 | else | |
1092 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1093 | left() | |
1094 | inventorycheck() | |
1095 | refuel() | |
1096 | while dig() == true do | |
1097 | dig() | |
1098 | end | |
1099 | forward() | |
1100 | left() | |
1101 | else | |
1102 | right() | |
1103 | inventorycheck() | |
1104 | refuel() | |
1105 | while dig() == true do | |
1106 | dig() | |
1107 | end | |
1108 | forward() | |
1109 | right() | |
1110 | end | |
1111 | end | |
1112 | else | |
1113 | end | |
1114 | end | |
1115 | end | |
1116 | if a < h then | |
1117 | while digup() == true do --this is to go up to next layer | |
1118 | digup() | |
1119 | end | |
1120 | up() | |
1121 | right() | |
1122 | right() | |
1123 | else | |
1124 | end | |
1125 | end | |
1126 | elseif w == h and l == h then | |
1127 | for a = 1, h do | |
1128 | for b = 1, w do --this digs into the cube | |
1129 | for c = 1, (l-1) do --this digs the length | |
1130 | while dig() == true do | |
1131 | dig() | |
1132 | end | |
1133 | forward() | |
1134 | end | |
1135 | if w%2 == 1 then | |
1136 | if b < w then | |
1137 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1138 | right() | |
1139 | inventorycheck() | |
1140 | refuel() | |
1141 | while dig() == true do | |
1142 | dig() | |
1143 | end | |
1144 | forward() | |
1145 | right() | |
1146 | else | |
1147 | left() | |
1148 | inventorycheck() | |
1149 | refuel() | |
1150 | while dig() == true do | |
1151 | dig() | |
1152 | end | |
1153 | forward() | |
1154 | left() | |
1155 | end | |
1156 | else | |
1157 | end | |
1158 | else -- this is the nightmare scenario where the width is even causing the turns to be different from layer to layer | |
1159 | if b < w then | |
1160 | if a%2 == 1 then | |
1161 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1162 | right() | |
1163 | inventorycheck() | |
1164 | refuel() | |
1165 | while dig() == true do | |
1166 | dig() | |
1167 | end | |
1168 | forward() | |
1169 | right() | |
1170 | else | |
1171 | left() | |
1172 | inventorycheck() | |
1173 | refuel() | |
1174 | while dig() == true do | |
1175 | dig() | |
1176 | end | |
1177 | forward() | |
1178 | left() | |
1179 | end | |
1180 | else | |
1181 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1182 | left() | |
1183 | inventorycheck() | |
1184 | refuel() | |
1185 | while dig() == true do | |
1186 | dig() | |
1187 | end | |
1188 | forward() | |
1189 | left() | |
1190 | else | |
1191 | right() | |
1192 | inventorycheck() | |
1193 | refuel() | |
1194 | while dig() == true do | |
1195 | dig() | |
1196 | end | |
1197 | forward() | |
1198 | right() | |
1199 | end | |
1200 | end | |
1201 | else | |
1202 | end | |
1203 | end | |
1204 | end | |
1205 | if a < h then | |
1206 | while digup() == true do --this is to go up to next layer | |
1207 | digup() | |
1208 | end | |
1209 | up() | |
1210 | right() | |
1211 | right() | |
1212 | else | |
1213 | end | |
1214 | end | |
1215 | end | |
1216 | backtostart() | |
1217 | clearinventory() | |
1218 | end | |
1219 | ||
1220 | function digcubetopleft() --efficiently mines out an area determined by the user | |
1221 | - | print("Place coal blocks or coal in slot 1. Also place a stack of cobblestone in slots 2, 3, 4. Also dig a pit trap 2 blocks in front of the turtle in case a mob spawns in front of it.") |
1221 | + | print("Place coal blocks or coal in slot 1. Also dig a pit trap 2 blocks in front of the turtle in case a mob spawns in front of it. (optional but could slightly speed up process)") |
1222 | ||
1223 | print("What is the width? this number expands to the right with the first part of the cube being in front of the turtle.") | |
1224 | w = tonumber(read()) | |
1225 | ||
1226 | print("What is the length? This number expands into the area you are excavating.") | |
1227 | l = tonumber(read()) | |
1228 | ||
1229 | print("What is the height? This number is the how many blocks up the cube expands up from starting position") | |
1230 | h = tonumber(read()) | |
1231 | ||
1232 | print("what is the current direction the turtle is facing? (type 1 for north, 2 for east, 3 for south and 4 for west)") | |
1233 | heading = tonumber(read()) | |
1234 | ||
1235 | while dig() == true do --this get the turtle into position | |
1236 | dig() | |
1237 | end | |
1238 | forward() | |
1239 | if l > w and l > h then --if the cube has a long length like a tunnel this will be the function it follows | |
1240 | for a = 1, h do | |
1241 | for b = 1, w do --this digs into the cube | |
1242 | for c = 1, (l-1) do --this digs the length | |
1243 | while dig() == true do | |
1244 | dig() | |
1245 | end | |
1246 | forward() | |
1247 | end | |
1248 | if w%2 == 1 then | |
1249 | if b < w then | |
1250 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1251 | right() | |
1252 | inventorycheck() | |
1253 | refuel() | |
1254 | while dig() == true do | |
1255 | dig() | |
1256 | end | |
1257 | forward() | |
1258 | right() | |
1259 | else | |
1260 | left() | |
1261 | inventorycheck() | |
1262 | refuel() | |
1263 | while dig() == true do | |
1264 | dig() | |
1265 | end | |
1266 | forward() | |
1267 | left() | |
1268 | end | |
1269 | else | |
1270 | end | |
1271 | else -- this is the nightmare scenario where the width is even causing the turns to be different from layer to layer | |
1272 | if b < w then | |
1273 | if a%2 == 1 then | |
1274 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1275 | right() | |
1276 | inventorycheck() | |
1277 | refuel() | |
1278 | while dig() == true do | |
1279 | dig() | |
1280 | end | |
1281 | forward() | |
1282 | right() | |
1283 | else | |
1284 | left() | |
1285 | inventorycheck() | |
1286 | refuel() | |
1287 | while dig() == true do | |
1288 | dig() | |
1289 | end | |
1290 | forward() | |
1291 | left() | |
1292 | end | |
1293 | else | |
1294 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1295 | left() | |
1296 | inventorycheck() | |
1297 | refuel() | |
1298 | while dig() == true do | |
1299 | dig() | |
1300 | end | |
1301 | forward() | |
1302 | left() | |
1303 | else | |
1304 | right() | |
1305 | inventorycheck() | |
1306 | refuel() | |
1307 | while dig() == true do | |
1308 | dig() | |
1309 | end | |
1310 | forward() | |
1311 | right() | |
1312 | end | |
1313 | end | |
1314 | else | |
1315 | end | |
1316 | end | |
1317 | end | |
1318 | if a < h then | |
1319 | while digdown() == true do --this is to go up to next layer | |
1320 | digdown() | |
1321 | end | |
1322 | down() | |
1323 | right() | |
1324 | right() | |
1325 | else | |
1326 | end | |
1327 | end | |
1328 | elseif w > l and w > h then -- this is when the width is greater than the length and height | |
1329 | for d = 1 , l-1 do | |
1330 | while dig() == true do | |
1331 | dig() | |
1332 | end | |
1333 | forward() | |
1334 | end | |
1335 | right() | |
1336 | for a = 1, h do | |
1337 | for b = 1, l do --this digs into the cube | |
1338 | for c = 1, (w-1) do --this digs the length | |
1339 | while dig() == true do | |
1340 | dig() | |
1341 | end | |
1342 | forward() | |
1343 | end | |
1344 | if w%2 == 1 then | |
1345 | if b < l then | |
1346 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1347 | right() | |
1348 | inventorycheck() | |
1349 | refuel() | |
1350 | while dig() == true do | |
1351 | dig() | |
1352 | end | |
1353 | forward() | |
1354 | right() | |
1355 | else | |
1356 | left() | |
1357 | inventorycheck() | |
1358 | refuel() | |
1359 | while dig() == true do | |
1360 | dig() | |
1361 | end | |
1362 | forward() | |
1363 | left() | |
1364 | end | |
1365 | else | |
1366 | end | |
1367 | else -- this is the nightmare scenario where the width is even causing the turns to be different from layer to layer | |
1368 | if b < l then | |
1369 | if a%2 == 1 then | |
1370 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1371 | right() | |
1372 | inventorycheck() | |
1373 | refuel() | |
1374 | while dig() == true do | |
1375 | dig() | |
1376 | end | |
1377 | forward() | |
1378 | right() | |
1379 | else | |
1380 | left() | |
1381 | inventorycheck() | |
1382 | refuel() | |
1383 | while dig() == true do | |
1384 | dig() | |
1385 | end | |
1386 | forward() | |
1387 | left() | |
1388 | end | |
1389 | else | |
1390 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1391 | left() | |
1392 | inventorycheck() | |
1393 | refuel() | |
1394 | while dig() == true do | |
1395 | dig() | |
1396 | end | |
1397 | forward() | |
1398 | left() | |
1399 | else | |
1400 | right() | |
1401 | inventorycheck() | |
1402 | refuel() | |
1403 | while dig() == true do | |
1404 | dig() | |
1405 | end | |
1406 | forward() | |
1407 | right() | |
1408 | end | |
1409 | end | |
1410 | else | |
1411 | end | |
1412 | end | |
1413 | end | |
1414 | if a < h then | |
1415 | while digdown() == true do --this is to go up to next layer | |
1416 | digdown() | |
1417 | end | |
1418 | down() | |
1419 | right() | |
1420 | right() | |
1421 | else | |
1422 | end | |
1423 | end | |
1424 | elseif h > w and h > l then | |
1425 | for a = 1, w do | |
1426 | for b = 1, l do --this digs into the cube | |
1427 | for c = 1, (h-1) do --this digs the length | |
1428 | if l%2 == 1 then | |
1429 | if a%2 == 1 then | |
1430 | if b%2 == 1 then | |
1431 | while digdown() == true do | |
1432 | digdown() | |
1433 | end | |
1434 | down() | |
1435 | else | |
1436 | while digup() == true do | |
1437 | digup() | |
1438 | end | |
1439 | up() | |
1440 | end | |
1441 | else | |
1442 | if b%2 == 1 then | |
1443 | while digup() == true do | |
1444 | digup() | |
1445 | end | |
1446 | up() | |
1447 | else | |
1448 | while digdown() == true do | |
1449 | digdown() | |
1450 | end | |
1451 | down() | |
1452 | end | |
1453 | ||
1454 | end | |
1455 | else | |
1456 | if b%2 == 1 then | |
1457 | while digdown() == true do | |
1458 | digdown() | |
1459 | end | |
1460 | down() | |
1461 | else | |
1462 | while digup() == true do | |
1463 | digup() | |
1464 | end | |
1465 | up() | |
1466 | end | |
1467 | end | |
1468 | end | |
1469 | if b < l then | |
1470 | while dig() == true do | |
1471 | dig() | |
1472 | end | |
1473 | forward() | |
1474 | inventorycheck() | |
1475 | refuel() | |
1476 | ||
1477 | else | |
1478 | end | |
1479 | end | |
1480 | if a < w then | |
1481 | if a%2 == 1 then | |
1482 | right() | |
1483 | inventorycheck() | |
1484 | refuel() | |
1485 | while dig() == true do | |
1486 | dig() | |
1487 | end | |
1488 | forward() | |
1489 | right() | |
1490 | else | |
1491 | left() | |
1492 | inventorycheck() | |
1493 | refuel() | |
1494 | while dig() == true do | |
1495 | dig() | |
1496 | end | |
1497 | forward() | |
1498 | left() | |
1499 | end | |
1500 | else | |
1501 | end | |
1502 | end | |
1503 | elseif w == l then | |
1504 | for a = 1, h do | |
1505 | for b = 1, w do --this digs into the cube | |
1506 | for c = 1, (l-1) do --this digs the length | |
1507 | while dig() == true do | |
1508 | dig() | |
1509 | end | |
1510 | forward() | |
1511 | end | |
1512 | if w%2 == 1 then | |
1513 | if b < w then | |
1514 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1515 | right() | |
1516 | inventorycheck() | |
1517 | refuel() | |
1518 | while dig() == true do | |
1519 | dig() | |
1520 | end | |
1521 | forward() | |
1522 | right() | |
1523 | else | |
1524 | left() | |
1525 | inventorycheck() | |
1526 | refuel() | |
1527 | while dig() == true do | |
1528 | dig() | |
1529 | end | |
1530 | forward() | |
1531 | left() | |
1532 | end | |
1533 | else | |
1534 | end | |
1535 | else -- this is the nightmare scenario where the width is even causing the turns to be different from layer to layer | |
1536 | if b < w then | |
1537 | if a%2 == 1 then | |
1538 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1539 | right() | |
1540 | inventorycheck() | |
1541 | refuel() | |
1542 | while dig() == true do | |
1543 | dig() | |
1544 | end | |
1545 | forward() | |
1546 | right() | |
1547 | else | |
1548 | left() | |
1549 | inventorycheck() | |
1550 | refuel() | |
1551 | while dig() == true do | |
1552 | dig() | |
1553 | end | |
1554 | forward() | |
1555 | left() | |
1556 | end | |
1557 | else | |
1558 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1559 | left() | |
1560 | inventorycheck() | |
1561 | refuel() | |
1562 | while dig() == true do | |
1563 | dig() | |
1564 | end | |
1565 | forward() | |
1566 | left() | |
1567 | else | |
1568 | - | refuel() |
1568 | + | |
1569 | - | inventorycheck() |
1569 | + | |
1570 | refuel() | |
1571 | while dig() == true do | |
1572 | dig() | |
1573 | end | |
1574 | forward() | |
1575 | right() | |
1576 | end | |
1577 | - | refuel() |
1577 | + | |
1578 | - | inventorycheck() |
1578 | + | |
1579 | end | |
1580 | end | |
1581 | end | |
1582 | if a < h then | |
1583 | while digdown() == true do --this is to go up to next layer | |
1584 | digdown() | |
1585 | end | |
1586 | down() | |
1587 | right() | |
1588 | right() | |
1589 | else | |
1590 | end | |
1591 | end | |
1592 | elseif w == h then | |
1593 | for d = 1 , l-1 do | |
1594 | while dig() == true do | |
1595 | dig() | |
1596 | end | |
1597 | forward() | |
1598 | end | |
1599 | right() | |
1600 | for a = 1, h do | |
1601 | for b = 1, l do --this digs into the cube | |
1602 | for c = 1, (w-1) do --this digs the length | |
1603 | while dig() == true do | |
1604 | dig() | |
1605 | end | |
1606 | forward() | |
1607 | end | |
1608 | if w%2 == 1 then | |
1609 | if b < l then | |
1610 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1611 | right() | |
1612 | inventorycheck() | |
1613 | refuel() | |
1614 | while dig() == true do | |
1615 | dig() | |
1616 | end | |
1617 | forward() | |
1618 | right() | |
1619 | else | |
1620 | left() | |
1621 | inventorycheck() | |
1622 | refuel() | |
1623 | while dig() == true do | |
1624 | dig() | |
1625 | end | |
1626 | forward() | |
1627 | left() | |
1628 | end | |
1629 | else | |
1630 | end | |
1631 | else -- this is the nightmare scenario where the width is even causing the turns to be different from layer to layer | |
1632 | if b < l then | |
1633 | if a%2 == 1 then | |
1634 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1635 | right() | |
1636 | inventorycheck() | |
1637 | refuel() | |
1638 | while dig() == true do | |
1639 | dig() | |
1640 | end | |
1641 | forward() | |
1642 | right() | |
1643 | else | |
1644 | left() | |
1645 | inventorycheck() | |
1646 | refuel() | |
1647 | while dig() == true do | |
1648 | dig() | |
1649 | end | |
1650 | forward() | |
1651 | left() | |
1652 | end | |
1653 | else | |
1654 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1655 | left() | |
1656 | inventorycheck() | |
1657 | refuel() | |
1658 | while dig() == true do | |
1659 | dig() | |
1660 | end | |
1661 | forward() | |
1662 | left() | |
1663 | else | |
1664 | right() | |
1665 | inventorycheck() | |
1666 | refuel() | |
1667 | while dig() == true do | |
1668 | dig() | |
1669 | end | |
1670 | forward() | |
1671 | right() | |
1672 | end | |
1673 | end | |
1674 | else | |
1675 | end | |
1676 | end | |
1677 | end | |
1678 | if a < h then | |
1679 | while digdown() == true do --this is to go up to next layer | |
1680 | digdown() | |
1681 | end | |
1682 | down() | |
1683 | right() | |
1684 | right() | |
1685 | else | |
1686 | end | |
1687 | end | |
1688 | elseif h == l then | |
1689 | for a = 1, h do | |
1690 | for b = 1, w do --this digs into the cube | |
1691 | for c = 1, (l-1) do --this digs the length | |
1692 | while dig() == true do | |
1693 | dig() | |
1694 | end | |
1695 | forward() | |
1696 | end | |
1697 | if w%2 == 1 then | |
1698 | if b < w then | |
1699 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1700 | right() | |
1701 | inventorycheck() | |
1702 | refuel() | |
1703 | while dig() == true do | |
1704 | dig() | |
1705 | end | |
1706 | forward() | |
1707 | right() | |
1708 | else | |
1709 | left() | |
1710 | inventorycheck() | |
1711 | refuel() | |
1712 | while dig() == true do | |
1713 | dig() | |
1714 | end | |
1715 | forward() | |
1716 | left() | |
1717 | end | |
1718 | else | |
1719 | end | |
1720 | else -- this is the nightmare scenario where the width is even causing the turns to be different from layer to layer | |
1721 | if b < w then | |
1722 | if a%2 == 1 then | |
1723 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1724 | right() | |
1725 | inventorycheck() | |
1726 | refuel() | |
1727 | while dig() == true do | |
1728 | dig() | |
1729 | end | |
1730 | forward() | |
1731 | right() | |
1732 | else | |
1733 | left() | |
1734 | inventorycheck() | |
1735 | refuel() | |
1736 | while dig() == true do | |
1737 | dig() | |
1738 | end | |
1739 | forward() | |
1740 | left() | |
1741 | end | |
1742 | else | |
1743 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1744 | left() | |
1745 | inventorycheck() | |
1746 | refuel() | |
1747 | while dig() == true do | |
1748 | dig() | |
1749 | end | |
1750 | forward() | |
1751 | left() | |
1752 | else | |
1753 | right() | |
1754 | inventorycheck() | |
1755 | refuel() | |
1756 | while dig() == true do | |
1757 | dig() | |
1758 | end | |
1759 | forward() | |
1760 | right() | |
1761 | end | |
1762 | end | |
1763 | else | |
1764 | end | |
1765 | end | |
1766 | end | |
1767 | if a < h then | |
1768 | while digdown() == true do --this is to go up to next layer | |
1769 | digdown() | |
1770 | end | |
1771 | down() | |
1772 | right() | |
1773 | right() | |
1774 | else | |
1775 | end | |
1776 | end | |
1777 | elseif w == h and l == h then | |
1778 | for a = 1, h do | |
1779 | for b = 1, w do --this digs into the cube | |
1780 | for c = 1, (l-1) do --this digs the length | |
1781 | while dig() == true do | |
1782 | dig() | |
1783 | end | |
1784 | forward() | |
1785 | end | |
1786 | if w%2 == 1 then | |
1787 | if b < w then | |
1788 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1789 | right() | |
1790 | inventorycheck() | |
1791 | refuel() | |
1792 | while dig() == true do | |
1793 | dig() | |
1794 | end | |
1795 | forward() | |
1796 | right() | |
1797 | else | |
1798 | left() | |
1799 | inventorycheck() | |
1800 | refuel() | |
1801 | while dig() == true do | |
1802 | dig() | |
1803 | end | |
1804 | forward() | |
1805 | left() | |
1806 | end | |
1807 | else | |
1808 | end | |
1809 | else -- this is the nightmare scenario where the width is even causing the turns to be different from layer to layer | |
1810 | if b < w then | |
1811 | if a%2 == 1 then | |
1812 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1813 | right() | |
1814 | inventorycheck() | |
1815 | refuel() | |
1816 | while dig() == true do | |
1817 | dig() | |
1818 | end | |
1819 | forward() | |
1820 | right() | |
1821 | else | |
1822 | left() | |
1823 | inventorycheck() | |
1824 | refuel() | |
1825 | while dig() == true do | |
1826 | dig() | |
1827 | end | |
1828 | - | print("You can choose from two directions to dig. From top left down and to the right, or from bottom left up and to the right. 1 for top left and 2 for bottom left. If you are mining below 16 place the turtle at 16 and have it dig top left down.") |
1828 | + | |
1829 | left() | |
1830 | end | |
1831 | else | |
1832 | if b%2 == 1 then --this checks to see if it needs to go right or left odd b needs to go right | |
1833 | left() | |
1834 | inventorycheck() | |
1835 | refuel() | |
1836 | while dig() == true do | |
1837 | dig() | |
1838 | end | |
1839 | forward() | |
1840 | left() | |
1841 | else | |
1842 | right() | |
1843 | inventorycheck() | |
1844 | refuel() | |
1845 | while dig() == true do | |
1846 | dig() | |
1847 | end | |
1848 | forward() | |
1849 | right() | |
1850 | end | |
1851 | end | |
1852 | else | |
1853 | end | |
1854 | end | |
1855 | end | |
1856 | if a < h then | |
1857 | while digdown() == true do --this is to go up to next layer | |
1858 | digdown() | |
1859 | end | |
1860 | down() | |
1861 | right() | |
1862 | right() | |
1863 | else | |
1864 | end | |
1865 | end | |
1866 | end | |
1867 | backtostart() | |
1868 | clearinventory() | |
1869 | end | |
1870 | ||
1871 | ||
1872 | -- MAIN PROGRAM ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
1873 | ||
1874 | x_i = 0 --this is if you are not using gps and not getting real world coords | |
1875 | y_i = 0 | |
1876 | z_i = 0 | |
1877 | ||
1878 | x_c_f = 0 --stands for *_current_final represents the last position the turtle was at before it stopped mining | |
1879 | y_c_f = 0 | |
1880 | z_c_f = 0 | |
1881 | ||
1882 | x_c_i = 0 --you need x_c_i and such as a placeholder in function forward to keep values increasing or decreasing | |
1883 | y_c_i = 0 | |
1884 | z_c_i = 0 | |
1885 | ||
1886 | print("You can choose from two directions to dig. From top left down and to the right, or from bottom left up and to the right. 1 for top left and 2 for bottom left.") | |
1887 | ||
1888 | direction = tonumber(read()) | |
1889 | if direction == 1 then | |
1890 | digcubetopleft() | |
1891 | elseif direction == 2 then | |
1892 | digcubebottomleft() | |
1893 | end |