View difference between Paste ID: TyVqJxGQ and iCTwXr3T
SHOW: | | - or go back to the newest paste.
1
--Pastebin code: iCTwXr3T
2
3
--For people like stray, that only read the top of the code, and then gives up...
4
--if you didn't give up already, look below Straymav xD
5
--Put coal in slot #16, torches #15, ender chest for dropping items #14
6
--Also put a chest behind the turtle, if you want it to drop the loot it finds
7
--Put a chest to the left of the turtle, to resupply it with torches
8
9
--Info about the Default mode: 
10
   --the cycles it will run is 20
11
   --You can still choose what the branch-lenght is! using the "stripmine <number>"
12
   --It uses/tries to use torches
13
   --It uses/tries to use chests
14
   --It digs in Speed-Mode
15
   --It uses Wait-mode 
16
   --It has 2 spaces between each tunnel
17
   --It goes back to the starting position, when done
18
   --The space between the torches is 6
19
--end
20
21
shell.run("clear")
22
term.setCursorPos(1, 1)
23
24
local tArgs = {...}
25
if #tArgs > 1 or #tArgs < 1 then
26
   print("I need 1 argument, for the branch-lenght")
27
   print("so feks. write: stripmine 2")
28
   return
29
end
30
31
local branchMode = 0
32
local position = 0
33
local positionLeft = 0
34
local positionRight = 0
35
36
local positionTorch = 0
37
local positionLeftTorch = 0
38
local positionRightTorch = 0
39
local torchMode = 0
40
41
local endChest = 0
42
local itemSubtract = 15
43
local chestMode = 0
44
local waitMode = 0
45
local IC = 0
46
47
local check = 0
48
49
function gravelStripmine()
50
51
   for i = 1, FrontTunnel do
52
      gravelDig()
53
      positionTorch = positionTorch+1
54
      position = position+1
55
      chestDrop()
56
      endChestDrop()
57
      TorchCheckPlace()
58
   end
59
   turtle.turnLeft()
60
   positionLeft = 0
61
   positionLeftTorch = 0
62
   for i = 1, tArgs[1] do
63
      gravelDig()
64
      positionLeftTorch = positionLeftTorch+1
65
      positionLeft = positionLeft+1
66
      chestDrop()
67
      endChestDrop()
68
      TorchCheckPlace()
69
   end
70
   moveBack()
71
   positionLeftTorch = 0
72
   positionLeft = 0
73
   turtle.turnRight()
74
   turtle.turnRight()
75
   positionRight = 0
76
   positionRightTorch = 0
77
   for i = 1, tArgs[1] do
78
      gravelDig()
79
      positionRightTorch = positionRightTorch+1
80
      positionRight = positionRight+1
81
      chestDrop()
82
      endChestDrop()
83
      TorchCheckPlace()
84
   end
85
   moveBack()
86
   positionRightTorch = 0
87
   positionRight = 0
88
   turtle.turnLeft()
89
   chestDrop()
90
   endChestDrop()
91
end
92
93
function speedStripmine()
94
   
95
   for i = 1, FrontTunnel do
96
      speedDig()
97
      positionTorch = positionTorch+1 
98
      position = position + 1
99
      chestDrop()
100
      endChestDrop()
101
      TorchCheckPlace()
102
   end
103
   turtle.turnLeft()
104
   positionLeftTorch = 0
105
   positionLeft = 0
106
   for i = 1, tArgs[1] do
107
      speedDig()
108
      positionLeftTorch = positionLeftTorch+1
109
      positionLeft = positionLeft+1
110
      chestDrop()
111
      endChestDrop()
112
      TorchCheckPlace()
113
   end
114
   moveBack()
115
   positionLeftTorch = 0
116
   positionLeft = 0
117
   turtle.turnRight()
118
   turtle.turnRight()
119
   positionRightTorch = 0
120
   positionRight = 0
121
   for i = 1, tArgs[1] do
122
      speedDig()
123
      positionRightTorch = positionRightTorch+1
124
      positionRight = positionRight+1
125
      chestDrop()
126
      endChestDrop()
127
      TorchCheckPlace()
128
   end
129
   moveBack()
130
   positionRightTorch = 0
131
   positionRight = 0
132
   turtle.turnLeft()
133
   chestDrop()
134
   endChestDrop()
135
end
136
137
function endChestDrop()
138
139
   if endChest == 1 then
140
     itemSlot = 0
141
     for i = 1, 64 do
142
            itemSlot = itemSlot+1
143
               if turtle.getItemCount(13) == itemSlot then
144
                  slot = 0
145
                  for i = 1, 13 do
146
                     slot = slot+1
147
                     turtle.select(slot)
148
                        if turtle.compareTo(16) == true then
149
                           turtle.transferTo(16)
150
                        end
151
                     end
152
                     turtle.select(14)
153
                     while turtle.placeUp() == false do
154
                        if turtle.detectUp() == true then
155
                           turtle.digUp()
156
                           sleep(0.6)
157
                        end
158
                     end   
159
                     if torchMode == 1 then
160
                        for i = 1, positionLeft do
161
                           moveBackChest()
162
                        end
163
                        if positionLeft > positionRight then  
164
                           turtle.turnRight()
165
                        end
166
                        for i = 1, positionRight do
167
                           moveBackChest()
168
                        end
169
                        if positionRight > positionLeft then
170
                           turtle.turnLeft()
171
                        end
172
                        for i = 1, position do
173
                           moveBackChest()
174
                        end
175
                        turtle.turnLeft()
176
                        turtle.select(15)
177
                        turtle.suck()
178
                        slot = 0
179
                        for i = 1, 14 do
180
                           slot = slot+1
181
                           turtle.select(slot)
182
                           if turtle.compareTo(15) == true then
183
                              turtle.transferTo(15)
184
                           end
185
                        end
186
                        slot = 0
187
                        for i = 1, 14 do
188
                           slot = slot+1
189
                           turtle.select(slot)
190
                           if turtle.compareTo(15) == true then
191
                              turtle.drop()
192
                           end
193
                        end
194
                        turtle.turnLeft()
195
                        for i = 1, position do
196
                           moveBackChest()
197
                        end
198
                        turtle.turnRight()
199
                        turtle.turnRight()
200
                        if positionRight > positionLeft then
201
                           turtle.turnRight()
202
                           for i = 1, positionRight do
203
                              speedDig()
204
                           end
205
                        end
206
                        if positionLeft > positionRight then
207
                           turtle.turnLeft()
208
                           for i = 1, positionLeft do
209
                              speedDig() 
210
                           end 
211
                        end
212
                     end
213
            slot = 0
214
            if turtle.detectUp() == true then   
215
               for i = 1, 13 do
216
                  slot = slot+1
217
                  turtle.select(slot)
218
                  while turtle.getItemCount(slot) > IC do
219
                     turtle.dropUp()
220
                     if turtle.getItemCount(slot) > IC then                        
221
                        print("Master, the chest has no space left!")
222
                        sleep(5)
223
                        shell.run("clear")
224
                        term.setCursorPos(1, 1)
225
                     end
226
                  end
227
               end
228
            end
229
            turtle.select(14)
230
            turtle.digUp()
231
         end
232
      end
233
   end
234
end
235
236
function chestDrop()
237
   
238
   IC1 = turtle.getItemCount(14)
239
   if chestMode == 1 then
240
      itemSlot = 0
241
         for i = 1, 64 do
242
            itemSlot = itemSlot+1
243
               if turtle.getItemCount(itemSubtract) == itemSlot then
244
                  for i = 1, positionLeft do
245
                     moveBackChest()
246
                  end
247
                  if positionLeft > positionRight then  
248
                     turtle.turnRight()
249
                  end
250
                  for i = 1, positionRight do
251
                     moveBackChest()
252
                  end
253
                  if positionRight > positionLeft then
254
                     turtle.turnLeft()
255
                  end
256
                  for i = 1, position do
257
                     moveBackChest()
258
                  end
259
                  turtle.turnRight()
260
                  turtle.turnRight()
261
                  slot = 0
262
                  if torchMode == 1 then
263
                     turtle.turnRight()
264
                     turtle.select(15)
265
                     turtle.suck()
266
                     for i = 1, itemSubtract do
267
                        slot = slot+1
268
                        turtle.select(slot)
269
                           if turtle.compareTo(15) == true then
270
                              turtle.transferTo(15)
271
                           end
272
                        end
273
                        slot = 0
274
                        for i = 1, itemSubtract do
275
                           slot = slot+1
276
                           turtle.select(slot)
277
                              if turtle.compareTo(15) == true then
278
                                 turtle.drop()
279
                           end
280
                        end
281
                        turtle.turnLeft() 
282
                     end
283
                  slot = 0
284
                  for i = 1, itemSubtract do
285
                     slot = slot+1
286
                     turtle.select(slot)
287
                        if turtle.compareTo(16) == true then
288
                           turtle.transferTo(16)
289
                        end
290
                     end
291
                  slot = 0
292
                  if turtle.detect() == true then
293
                     if waitMode == 1 then
294
                        for i = 1, itemSubtract do
295
                           slot = slot+1
296
                           turtle.select(slot)
297
                           while turtle.getItemCount(slot) > IC do
298
                              turtle.drop()
299
                              if turtle.getItemCount(slot) > IC then                        
300
                                 print("Master, the chest has no space left!")
301
                                 sleep(5)
302
                                 shell.run("clear")
303
                                 term.setCursorPos(1, 1)
304
                              end   
305
                           end
306
                        end
307
                     end
308
                     slot = 0
309
                     if waitMode == 0 then
310
                        for i = 1, itemSubtract do
311
                           slot = slot+1
312
                           turtle.select(slot)
313
                           turtle.drop()
314
                        end
315
                     end
316
                  end
317
                  for i = 1, position do
318
                     moveBackChest()
319
                  end
320
               turtle.turnRight()
321
               turtle.turnRight()
322
               if positionRight > positionLeft then
323
                  turtle.turnRight()
324
               for i = 1, positionRight do
325
                  speedDig()
326
               end
327
            end
328
            if positionLeft > positionRight then
329
               turtle.turnLeft()
330
               for i = 1, positionLeft do
331
                  speedDig() 
332
               end
333
            end
334
         end
335
      end
336
   end
337
end
338
339
function checkFuel()
340
   
341
   turtle.select(1)  
342
   while turtle.getFuelLevel() == 0 do
343
      term.setCursorPos(1, 1)
344
      shell.run("clear")
345
      print("I am out of fuel my Master, refuel me and i will reboot!")
346
      sleep(2)
347
      slot = 0
348
      itemSlot = 0
349
      for i = 1, 64 do
350
         itemSlot = itemSlot+1
351
         for i = 1, 16 do
352
            slot = slot+1
353
            if turtle.getItemCount(slot) == itemSlot then
354
               turtle.select(slot)
355
               turtle.refuel(1)
356
            end
357
         end
358
        slot = 0
359
      end
360
   end
361
   term.setCursorPos(1, 1)
362
   shell.run("clear")
363
   print("I refueled succesfully my Master!")
364
end
365
366
function gravelDig()
367
   
368
   turtle.select(1)
369
   BlockBreakCount = 0
370
   while BlockBreakCount < 30 do
371
      while turtle.digUp() == true do
372
         sleep(0.6)
373
      end
374
      BlockBreakCount = BlockBreakCount+1
375
   end
376
    BlockBreakCount = 0
377
    while turtle.forward() == false do
378
      checkFuel()
379
      while turtle.attack() == true do
380
         sleep(1)
381
      end
382
      while BlockBreakCount < 30 do
383
         if turtle.dig() == true then
384
            sleep(0.4)
385
         end
386
         BlockBreakCount = BlockBreakCount+1
387
      end
388
      if torchMode == 1 then 
389
         if turtle.detectDown() == true then
390
            turtle.select(15)
391
            if turtle.compareDown() == false then
392
               turtle.select(1)
393
               turtle.digDown()
394
            end
395
         end
396
         else
397
         turtle.digDown()
398
      end
399
   end
400
end
401
402
function speedDig()
403
   
404
   turtle.select(1)
405
   turtle.digUp()
406
   turtle.dig()
407
   if torchMode == 1 then
408
      if turtle.detectDown() == true then
409
         turtle.select(15)
410
         if turtle.compareDown() == false then
411
            turtle.select(1) 
412
            turtle.digDown()
413
         end
414
      end
415
      else
416
      turtle.digDown()
417
   end
418
   BlockBreakCount = 0
419
   while turtle.forward() == false do
420
      checkFuel()
421
      turtle.attack()
422
      while BlockBreakCount < 30 do
423
         turtle.dig()
424
         BlockBreakCount = BlockBreakCount+1
425
      end
426
   end 
427
end  
428
429
function TorchCheckPlace()
430
431
   if torchMode == 1 then
432
      Input6 = Input6+1
433
      if turtle.getItemCount(15) == 0 then
434
         for i = 1, positionLeft do
435
            moveBackChest()
436
         end
437
         if positionLeft > positionRight then  
438
            turtle.turnRight()
439
         end
440
         for i = 1, positionRight do
441
            moveBackChest()
442
         end
443
         if positionRight > positionLeft then
444
            turtle.turnLeft()
445
         end
446
         for i = 1, position do
447
            moveBackChest()
448
         end
449
         turtle.turnLeft()
450
         while turtle.getItemCount(15) == 0 do
451
            turtle.select(15)
452
            turtle.suck()
453
            slot = 0
454
            for i = 1, itemSubtract do
455
               slot = slot+1
456
               turtle.select(slot)
457
               sleep(0.2)
458
               if turtle.compareTo(15) == true then
459
                  turtle.transferTo(15)
460
               end
461
            end
462
            slot = 0
463
            for i = 1, itemSubtract do
464
               slot = slot+1
465
               turtle.select(slot)
466
               sleep(0.2)
467
               if turtle.compareTo(15) == true then
468
                  turtle.drop()
469
                end
470
             end
471
          end
472
          turtle.turnLeft()          
473
          for i = 1, position do
474
             moveBackChest()
475
          end
476
          turtle.turnRight()
477
          turtle.turnRight()
478
          if positionRight > positionLeft then
479
             turtle.turnRight()
480
             for i = 1, positionRight do
481
                speedDig()
482
             end
483
          end
484
          if positionLeft > positionRight then
485
             turtle.turnLeft()
486
             for i = 1, positionLeft do
487
                speedDig() 
488
             end
489
          end
490
       end
491
       if positionTorch == Input6 then
492
         turtle.digDown()
493
         turtle.select(15)
494
         turtle.placeDown()
495
         turtle.select(1)
496
         positionTorch = positionTorch-Input6
497
      end
498
      Input6 = Input6-1
499
      Input6 = Input6+1
500
      if positionLeftTorch == Input6 then
501
         turtle.digDown()
502
         turtle.select(15)
503
         turtle.placeDown()
504
         turtle.select(1)
505
         positionLeftTorch = positionLeftTorch-Input6
506
      end
507
      Input6 = Input6-1
508
      Input6 = Input6+1
509
      if positionRightTorch == Input6 then
510
         turtle.digDown()
511
         turtle.select(15)
512
         turtle.placeDown()
513
         turtle.select(1)
514
         positionRightTorch = positionRightTorch-Input6
515
      end
516
      Input6 = Input6-1
517
   end
518
end
519
520
function moveBack()
521
   
522
   for i = 1, tArgs[1] do
523
      if turtle.back() == false then
524
         checkFuel()
525
         turtle.turnRight()
526
         turtle.turnRight()
527
         while turtle.attack() == true do
528
            sleep(1)
529
         end
530
         while turtle.dig() == true do
531
            sleep(0.6)
532
         end
533
         if turtle.forward() == false then
534
            speedDig()
535
         end
536
         turtle.turnRight()
537
         turtle.turnRight()
538
      end
539
   end
540
end
541
542
function moveBackChest()
543
   
544
   if turtle.back() == false then
545
      checkFuel()
546
      turtle.turnRight()
547
      turtle.turnRight()
548
      while turtle.attack() == true do
549
         sleep(1)
550
      end
551
      while turtle.dig() == true do
552
         sleep(0.6)
553
      end
554
      if turtle.forward() == false then
555
         speedDig()
556
      end
557
      turtle.turnRight()
558
      turtle.turnRight()
559
   end
560
end
561
562
print("Do you wish to use Default or Custom mode?")
563
print("write <default> or Press ENTER")
564
defaultCheck = read()
565
566
if defaultCheck == "default" then
567
   
568
   tArgs[1] = tArgs[1]+1
569
   itemSubtract = itemSubtract-1 
570
   Input2 = 20
571
   Input6 = 6
572
   FrontTunnel = 2
573
   branchMode = 2
574
   chestMode = 1
575
   waitMode = 1
576
   torchMode = 1
577
   FrontTunnel = FrontTunnel+1
578
   Input8 = "yes"
579
   shell.run("clear")
580
   term.setCursorPos(1, 1) 
581
582
   print("Put coal in slot #16, torches #15")
583
   print("Also put a chest behind the turtle, if you want it to drop the loot it finds")
584
   print("Put a chest to the left of the turtle, to resupply it with torches")
585
   print("Press ENTER to continue!")
586
   infoSkip = read()
587
588
   if branchMode == 2 then
589
      for i = 1, Input2 do
590
         speedStripmine()
591
      end
592
      if Input8 == "yes" then
593
         for i = 1, positionLeft do
594
            moveBackChest()
595
         end
596
         if positionLeft > positionRight then  
597
            turtle.turnRight()
598
         end
599
         for i = 1, positionRight do
600
            moveBackChest()
601
         end
602
         if positionRight > positionLeft then
603
            turtle.turnLeft()
604
         end
605
         for i = 1, position do
606
            moveBackChest()
607
         end
608
      end    
609
      print("I am done my Master!")
610
   end
611
   return
612
end
613
614
print("Write <speed> or <gravel> -Andersfc, the maker of this program")
615
print("He suggests using the speed-mode")
616
term.write("Speed-Mode or Gravel-Mode?>")
617
Input1 = read()
618
619
if Input1 == "speed" or Input1 == "gravel" then
620
  check = 0   
621
else
622
   shell.run("clear")
623
   print("You misstyped speed or gravel")
624
   return
625
end
626
627
shell.run("clear")
628
term.setCursorPos(1, 1)
629
630
print("Write the amount of cycles to run")
631
term.write("How many cycles?>")
632
Input2 = read()
633
634
shell.run("clear")
635
term.setCursorPos(1, 1)
636
637
print("Write <chest>, <enderchest> or <nochest>")
638
term.write("Master do you want chests?>")
639
Input3 = read()
640
641
if Input3 == "chest" or Input3 == "enderchest" or Input3 == "nochest" then
642
  check = 0   
643
else
644
   shell.run("clear")
645
   print("You misstyped chest, enderchest or nochest")
646
   return
647
end
648
649
shell.run("clear")
650
term.setCursorPos(1, 1)
651
652
if Input3 == "chest" then
653
   print("write <wait> or <nowait>, this mode is useful if your chest is full, then the turtle will")
654
   print("wait till the chest has room")
655
   term.write("Master should i wait?>")
656
   Input4 = read()
657
end
658
659
if Input4 == "wait" or Input4 == "nowait" then
660
  check = 0   
661
else
662
   shell.run("clear")
663
   print("You misstyped wait or nowait")
664
   return
665
end
666
667
if Input3 == "enderchest" then
668
   endChest = 1
669
end
670
671
shell.run("clear")
672
term.setCursorPos(1, 1)
673
674
print("write <torch> or <notorch> this mode is just used if you want torch-placing")
675
term.write("Master do you want torches?>")
676
Input5 = read()
677
678
if Input5 == "torch" or Input5 == "notorch" then
679
  check = 0   
680
else
681
   shell.run("clear")
682
   print("You misstyped torch or notorch")
683
   return
684
end
685
686
if Input5 == "torch" then
687
   itemSubtract = itemSubtract-1
688
end
689
690
if Input5 == "torch" then
691
   shell.run("clear")
692
   term.setCursorPos(1, 1) 
693
   print("Write the amount of space, between the torches")
694
   print("-Andersfc, the maker of this program, suggests to use about 6 blocks space between")
695
   print("If you dont want mob-spawns")
696
   term.write("How much space between the torches?>")
697
   Input6 = read()
698
end
699
700
shell.run("clear")
701
term.setCursorPos(1, 1)
702
703
print("Write the amount of space between the branch-tunnels")
704
print("-Andersfc, the maker of this program, suggests using 2-4 blocks space")
705
term.write("How much space between?>")
706
FrontTunnel = read()
707
708
shell.run("clear")
709
term.setCursorPos(1, 1)
710
711
print("Master, should i go back to my starting-position, when i'm done mining?")
712
print("Write <yes> or <no>")
713
term.write("Should i go back?>")
714
Input8 = read()
715
716
if Input8 == "yes" or Input1 == "no" then
717
  check = 0   
718
else
719
   shell.run("clear")
720
   print("You misstyped yes or no")
721
   return
722
end
723
724
shell.run("clear")
725
term.setCursorPos(1, 1) 
726
727
print("Put coal in slot #16, torches #15, ender chest for dropping items #14")
728
print("Also put a chest behind the turtle, if you want it to drop the loot it finds")
729
print("Put a chest to the left of the turtle, to resupply it with torches")
730
print("Press ENTER to continue!")
731
infoSkip = read()
732
733
tArgs[1] = tArgs[1]+1
734
735
if Input1 == "speed" then
736
   branchMode = 2
737
end
738
739
if Input1 == "gravel" then
740
   branchMode = 1
741
end
742
743
if Input3 == "chest" then
744
   chestMode = 1
745
end
746
747
if Input4 == "wait" then
748
   waitMode = 1
749
end
750
751
if Input5 == "torch" then
752
   torchMode = 1
753
end
754
755
FrontTunnel = FrontTunnel+1
756
757
if branchMode == 1 then
758
   for i = 1, Input2 do
759
      gravelStripmine()
760
   end
761
   if Input8 == "yes" then
762
      for i = 1, positionLeft do
763
         moveBackChest()
764
      end
765
      if positionLeft > positionRight then  
766
         turtle.turnRight()
767
      end
768
      for i = 1, positionRight do
769
         moveBackChest()
770
      end
771
      if positionRight > positionLeft then
772
         turtle.turnLeft()
773
      end
774
      for i = 1, position do
775
         moveBackChest()
776
      end
777
   end
778
print("I am done my Master!")
779
end
780
781
if branchMode == 2 then
782
   for i = 1, Input2 do
783
      speedStripmine()
784
   end
785
   if Input8 == "yes" then
786
      for i = 1, positionLeft do
787
         moveBackChest()
788
      end
789
      if positionLeft > positionRight then  
790
         turtle.turnRight()
791
      end
792
      for i = 1, positionRight do
793
         moveBackChest()
794
      end
795
      if positionRight > positionLeft then
796
         turtle.turnLeft()
797
      end
798
      for i = 1, position do
799
         moveBackChest()
800
      end
801
   end    
802
print("I am done my Master!")
803
end