-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuwc.lua
2032 lines (1865 loc) · 43.5 KB
/
uwc.lua
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--MENU
--VARIABLES
local version = "ULTIMATE WOOD CHOPPER BETA 0.9.0"
local w,h = term.getSize()
local select, distance, turtleslot = 1, 7, 1
local running, chopping, usebonemeal = true, true, true
local a, b, c, d, e, f, z = 6,7,8,9,10,11,h-2
turtle.select(turtleslot)
--VARIABLES
cancelTimer = 2
bonemealTimer = 120
bonemealFirstDelay = 0
amountMaxWoodSlotBonemeal = 14
amountMaxWoodSlotNoBonemeal = 7
amountMinBonemeal = 8
amountMinSaplings = 17
amountMinFuelLevel = 1200
amountFurnaceWoodBonemeal = 16
amountFurnaceWoodNoBonemeal = 8
debugMaxHeight = 55
function loadVariables()
local file = fs.open("uwcvariables","r")
cancelTimer = tonumber(file.readLine())
bonemealTimer = tonumber(file.readLine())
bonemealFirstDelay = tonumber(file.readLine())
amountMaxWoodSlotBonemeal = tonumber(file.readLine())
amountMaxWoodSlotNoBonemeal = tonumber(file.readLine())
amountMinBonemeal = tonumber(file.readLine())
amountMinSaplings = tonumber(file.readLine())
amountMinFuelLevel = tonumber(file.readLine())
amountFurnaceWoodBonemeal = tonumber(file.readLine())
amountFurnaceWoodNoBonemeal = tonumber(file.readLine())
debugMaxHeight = tonumber(file.readLine())
file.close()
end
function saveVariables()
if fs.exists("uwcvariables") then
fs.delete("uwcvariables")
end
sleep(0.5)
local file = fs.open("uwcvariables","w")
file.writeLine(cancelTimer)
file.writeLine(bonemealTimer)
file.writeLine(bonemealFirstDelay)
file.writeLine(amountMaxWoodSlotBonemeal)
file.writeLine(amountMaxWoodSlotNoBonemeal)
file.writeLine(amountMinBonemeal)
file.writeLine(amountMinSaplings)
file.writeLine(amountMinFuelLevel)
file.writeLine(amountFurnaceWoodBonemeal)
file.writeLine(amountFurnaceWoodNoBonemeal)
file.writeLine(debugMaxHeight)
file.close()
end
if fs.exists("uwcvariables") then
loadVariables()
else
saveVariables()
end
--PRINT
local function printCentered(str, ypos)
term.setCursorPos(w/2 - #str/2, ypos)
term.write(str)
end
local function printRight(str, ypos)
term.setCursorPos(w-#str, ypos)
term.write(str)
end
function clearScreen()
term.clear()
term.setCursorPos(1,1)
term.clear()
end
function drawHeader(title, line)
printCentered(title, line)
printCentered(string.rep("-", w), line+1)
end
function drawCopyright()
printRight("by UNOBTANIUM", h)
end
--MENUS
function drawMenuMain()
drawCopyright()
drawHeader(version, 1)
if select == 1 then
printCentered(">> Chop <<", a)
else
printCentered("Chop", a)
end
if select == 2 then
printCentered(">> Turtle Interactions <<", b)
else
printCentered("Turtle Interactions", b)
end
if select == 3 then
printCentered(">> Build and Expand <<", c)
else
printCentered("Build and Expand", c)
end
if select == 4 then
printCentered(">> Help <<", d)
else
printCentered("Help", d)
end
if select == 5 then
printCentered("> Credits <", e)
else
printCentered("Credits", e)
end
if select == 6 then
printCentered("> Quit <", 11)
else
printCentered("Quit", 11)
end
end
function drawMenuFarm()
drawHeader(version, 1)
if select == 1 then
printCentered(">> Farm <<", a)
else
printCentered("Farm", a)
end
if select == 2 then
printCentered(">> Single Tree <<", b)
else
printCentered("Single Tree",b)
end
if select == 3 then
printCentered("> Back <", z)
else
printCentered("Back", z)
end
end
function drawMenuChop()
drawHeader(version, 1)
drawHeader("FARM", 3)
if select == 1 then
printCentered("> Standard Farm <", a)
else
printCentered("Standard Farm", a)
end
if select == 2 then
printCentered("> Expanded Farm <", b)
else
printCentered("Expanded Farm", b)
end
if select == 3 then
printCentered("> Standard Farm without bonemeal <", c)
else
printCentered("Standard Farm without bonemeal", c)
end
if select == 4 then
printCentered("> Expanded Farm without bonemeal <", d)
else
printCentered("Expanded Farm without bonemeal", d)
end
if select == 5 then
printCentered("> Variables <", e)
else
printCentered("Variables", e)
end
if select == 6 then
printCentered("> Back <", z)
else
printCentered("Back", z)
end
end
function drawMenuBuild()
drawHeader(version, 1)
drawHeader("BUILD AND EXPAND", 3)
printCentered("Does the Turtle has all materials?",10)
if select == 1 then
printCentered("> Set up a farm <", a)
else
printCentered("Set up a farm", a)
end
if select == 2 then
printCentered("> Expand the farm <", b)
else
printCentered("Expand the farm", b)
end
if select == 3 then
printCentered("> Add more chests <", c)
else
printCentered("Add more chests", c)
end
if select == 4 then
printCentered("> Back <", 12)
else
printCentered("Back", 12)
end
end
function drawMenuHelpDebug()
drawHeader(version, 1)
drawHeader("DEBUG", 3)
if select == 1 then
printCentered("> Standard Farm <", a)
else
printCentered("Standard Farm", a)
end
if select == 2 then
printCentered("> Expanded Farm <", b)
else
printCentered("Expanded Farm", b)
end
if select == 3 then
printCentered("> Back <", z)
else
printCentered("Back", z)
end
end
function drawMenuHelpPrograms()
drawHeader(version, 1)
drawHeader("HELP PROGRAMS", 3)
if select == 1 then
printCentered("> Position <", a)
else
printCentered("Position", a)
end
if select == 2 then
printCentered("> Dig needed space <", b)
else
printCentered("Dig needed space", b)
end
if select == 3 then
printCentered(">> Debug <<", c)
else
printCentered("Debug", c)
end
if select == 4 then
printCentered("> Move Down <", d)
else
printCentered("Move Down", d)
end
if select == 5 then
printCentered("> Back <", z)
else
printCentered("Back", z)
end
end
function drawMenuHelp()
drawHeader(version, 1)
drawHeader("HELP", 3)
if select == 1 then
printCentered(">> Help Programs <<", a)
else
printCentered("Help Programs", a)
end
if select == 2 then
printCentered(">> Help Interface <<", b)
else
printCentered("Help Interface", b)
end
if select == 3 then
printCentered("> Back <", z)
else
printCentered("Back", z)
end
end
function drawMenuSingleTreeChop()
drawHeader(version, 1)
drawHeader("SINGLE TREE CHOP", 3)
if select == 1 then
printCentered("> General 1x1 Tree <", a)
else
printCentered("General 1x1 Tree", a)
end
if select == 2 then
printCentered("> General 2x2 Tree <", b)
else
printCentered("General 2x2 Tree", b)
end
if select == 3 then
printCentered("> Back <", z)
else
printCentered("Back", z)
end
end
function drawMenuTurtleInteractions()
drawHeader(version, 1)
drawHeader("TURTLE INTERACTIONS", 3)
if select == 1 then
printCentered(">> Movement <<", a)
else
printCentered("Movement", a)
end
if select == 2 then
printCentered(">> Actions <<", b)
else
printCentered("Actions", b)
end
if select == 3 then
printCentered("> Control <", c)
else
printCentered("Control", c)
end
if select == 4 then
printCentered("> Back <", z)
else
printCentered("Back", z)
end
end
function drawMenuTurtleMovement()
drawHeader(version, 1)
drawHeader("TURTLE MOVEMENT", 3)
if select == 1 then
printCentered("> Forward <", a)
else
printCentered("Forward", a)
end
if select == 2 then
printCentered("> Back <", b)
else
printCentered("Back", b)
end
if select == 3 then
printCentered("> Up <", c)
else
printCentered("Up", c)
end
if select == 4 then
printCentered("> Down <", d)
else
printCentered("Down", d)
end
if select == 5 then
printCentered("> Turn Left <", e)
else
printCentered("Turn Left", e)
end
if select == 6 then
printCentered("> Turn Right <", f)
else
printCentered("Turn Right", f)
end
if select == 7 then
printCentered("> Back <", 12)
else
printCentered("Back", 12)
end
end
function drawMenuTurtleActions()
drawHeader(version, 1)
drawHeader("TURTLE ACTIONS", 3)
if select == 1 then
printCentered("> Refuel <", a)
else
printCentered("Refuel", a)
end
if select == 2 then
printCentered(">> Dig <<", b)
else
printCentered("Dig", b)
end
if select == 3 then
printCentered("> Select <", c)
else
printCentered("Select", c)
end
if select == 4 then
printCentered("> Back <", z)
else
printCentered("Back", z)
end
end
function drawMenuTurtleDig()
drawHeader(version, 1)
drawHeader("TURTLE DIG", 3)
if select == 1 then
printCentered("> Up <", a)
else
printCentered("Up", a)
end
if select == 2 then
printCentered("> Front <", b)
else
printCentered("Front", b)
end
if select == 3 then
printCentered("> Down <", c)
else
printCentered("Down", c)
end
if select == 4 then
printCentered("> Back <", z)
else
printCentered("Back", z)
end
end
function drawMenuCredits()
drawHeader(version,1)
printCentered("all nicknames from the CC forums!!",3)
printCentered("- IDEA, CODEING & PUBLISHER -",5)
printCentered("unobtanium",6)
printCentered("- HELPING WITH CODING -",8)
printCentered("theoriginalbit, Mtdj2, NitrogenFingers", 9)
printCentered("- SPECIAL THANKS GOES TO -",11)
printCentered("Hoppingmad9, xInDiGo, Seleck",12)
printCentered("Permutation, PhilHibbs, DavEdward ",13)
read()
clearScreen()
drawHeader(version,1)
printCentered("- MENTIONABLES -",3)
printCentered("HotGirlEAN, snoxx, steel_toed_boot,",4)
printCentered("Zagi, Kylun, Kravyn, PhaxeNor, ughzug",5)
printCentered("sjkeegs, atlas, Minithra, TheFan",6)
printCentered("grumpysmurf, Quickslash78, lewanator1",7)
printCentered("behedwin, TESTimonSHOOTER",8)
printCentered("Kevironi, Fuzzlewhumper, Bigdavie",9)
printCentered("Viproz, Bigjimmy12, bomanski, punchin",10)
printCentered("oxgon, ahwtx, zilvar2k11",11)
printCentered("The_Ianator, Coolkrieger3", 12)
read()
clearScreen()
drawHeader(version,1)
printCentered(version,1)
printCentered("And last but not least",6)
printCentered("You, the users and players :D",7)
printCentered("Thank you everybody!!!", 10)
read()
end
--MENUSTATE
local menustate = "main"
local mopt = {
["main"] = {
options = {"mainchopprograms", "turtleinteractions" ,"buildprograms", "help", "credits","quit"},
draw = drawMenuMain
},
["mainchopprograms"] = {
options = {"farmprograms", "singletreechopprograms", "main"},
draw = drawMenuFarm
},
["farmprograms"] = {
options = {"standard", "expanded", "standardnobonemeal", "expandednobonemeal", "variables", "mainchopprograms"},
draw = drawMenuChop
},
["buildprograms"] = {
options = {"build","expand", "expandchests", "main"},
draw = drawMenuBuild
},
["singletreechopprograms"] = {
options = {"onebyone", "twobytwo", "mainchopprograms"},
draw = drawMenuSingleTreeChop
},
["help"] = {
options = {"helpprograms", "helpinterface", "main"},
draw = drawMenuHelp
},
["helpprograms"] = {
options = {"position", "digSpace", "helpdebugprograms", "godown", "help"},
draw = drawMenuHelpPrograms
},
["helpdebugprograms"] = {
options = {"debugstandard", "debugexpanded","helpprograms"},
draw = drawMenuHelpDebug
},
["turtleinteractions"] = {
options = {"turtlemovement", "turtleactions", "control", "main"},
draw = drawMenuTurtleInteractions
},
["turtlemovement"] = {
options = {"forward", "back", "up", "down", "left", "right" , "turtleinteractions"},
draw = drawMenuTurtleMovement
},
["turtleactions"] = {
options = {"refuel", "turtledig", "select", "turtleinteractions"},
draw = drawMenuTurtleActions
},
["turtledig"] = {
options = {"digup", "digfront", "digdown", "turtleactions"},
draw = drawMenuTurtleDig
}
}
--RUN MENU
function runMenu()
while true do
clearScreen()
mopt[menustate].draw()
local id, key = os.pullEvent("key")
if key == 200 or key == 17 then
select = select-1
end
if key == 208 or key == 31 then
select = select+1
end
if select == 0 then
select = #mopt[menustate].options
end
if select > #mopt[menustate].options then
select = 1
end
if key == 65 or key == 30 then
if not menustate == "quit" then
select = #mopt[menustate].options
menustate = mopt[menustate].options[select]
select = 1
else
clearScreen()
running = false
break
end
end
clearScreen()
if key == 28 or key == 32 then
if mopt[menustate].options[select] == "quit" then
running = false
break
elseif mopt[menustate].options[select] == "credits" then
drawMenuCredits()
elseif mopt[menustate].options[select] == "standard" then
usebonemeal = true
FWCchop()
elseif mopt[menustate].options[select] == "expanded" then
usebonemeal = true
FWCchop2()
elseif mopt[menustate].options[select] == "debugstandard" then
FWCdebugstandard()
elseif mopt[menustate].options[select] == "debugexpanded" then
FWCdebugexpanded()
elseif mopt[menustate].options[select] == "build" then
FWCbuild()
elseif mopt[menustate].options[select] == "expand" then
FWCexpand()
elseif mopt[menustate].options[select] == "helpinterface" then
FWChelp()
elseif mopt[menustate].options[select] == "position" then
FWCposition()
elseif mopt[menustate].options[select] == "expandchests" then
FWCexpandchests()
elseif mopt[menustate].options[select] == "onebyone" then
FWConebyone()
elseif mopt[menustate].options[select] == "twobytwo" then
FWCtwobytwo()
elseif mopt[menustate].options[select] == "standardnobonemeal" then
usebonemeal = false
FWCchop()
elseif mopt[menustate].options[select] == "expandednobonemeal" then
usebonemeal = false
FWCchop2()
elseif mopt[menustate].options[select] == "digSpace" then
FWCdigSpace()
elseif mopt[menustate].options[select] == "forward" then
turtle.forward()
elseif mopt[menustate].options[select] == "back" then
turtle.back()
elseif mopt[menustate].options[select] == "up" then
turtle.up()
elseif mopt[menustate].options[select] == "down" then
turtle.down()
elseif mopt[menustate].options[select] == "left" then
turtle.turnLeft()
elseif mopt[menustate].options[select] == "right" then
turtle.turnRight()
elseif mopt[menustate].options[select] == "refuel" then
turtle.refuel(1)
elseif mopt[menustate].options[select] == "select" then
turtleslot = turtleslot + 1
if turtleslot > 16 then turtleslot = 1 end
turtle.select(turtleslot)
elseif mopt[menustate].options[select] == "digup" then
turtle.digUp()
elseif mopt[menustate].options[select] == "digfront" then
turtle.dig()
elseif mopt[menustate].options[select] == "digdown" then
turtle.digDown()
elseif mopt[menustate].options[select] == "godown" then
UWCgodown()
elseif mopt[menustate].options[select] == "variables" then
UWCvariables()
elseif mopt[menustate].options[select] == "control" then
control()
elseif true then
menustate = mopt[menustate].options[select]
select = 1
end
end
end
end
--ULTIMATE WOOD CHOPPER PROGRAMS
--VARIABLES
local dirtexpand, pipeexpand, obsidianpipeexpand, blockslot, coal, chest, furnace, dirt, pipe, ironpipe, goldpipe, obsidianpipe, woodenpipe, engine, lever, bonemeal, stone1, stone2, stone3, sapling, fuel = 2,3,4,5,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,3
--MOVE FUNCTIONS
function forward()
while not turtle.forward() do end
end
function back()
while not turtle.back() do end
end
function up()
while not turtle.up() do end
end
function down()
while not turtle.down() do end
end
--MAIN CHOP PROGRAM FUNCTIONS
local function refreshItemStack(i)
turtle.select(3)
turtle.suck()
turtle.select(i)
turtle.drop()
turtle.select(3)
turtle.drop()
turtle.select(i)
turtle.suck()
if turtle.getItemCount(3) > 0 then
print("!!!!!!!!!")
print("The coal or sapling chest is full! Please take out some stacks, otherwise you lose items! The turtle will drop them!")
print("!!!!!!!!!")
turtle.select(3)
turtle.dropDown()
end
end
local function moveForward(j)
for i = 1,j do
forward()
end
end
local function getCoal()
local delay = os.startTimer(cancelTimer)
print("Taking coal out of the chest!")
print("If nothing happens the chest has too less materials!")
print("Press Enter to terminate process!")
while turtle.getFuelLevel() < amountMinFuelLevel do
event = { os.pullEvent() }
if event[1] == "timer" and event[2] == delay then
turtle.select(3)
turtle.suck()
if turtle.getItemCount(3) > 0 then
turtle.refuel(math.ceil((amountMinFuelLevel - turtle.getFuelLevel())/80))
turtle.drop()
if turtle.getFuelLevel() < amountMinFuelLevel then
delay = os.startTimer(2)
end
else
delay = os.startTimer(cancelTimer)
end
elseif event[1] == "key" and event[2] == 28 then
print("Terminated by User!")
clearScreen()
os.shutdown()
end
end
print("Succesful!")
end
local function getSaplings()
local taking = true
local delay = os.startTimer(cancelTimer)
print("Taking saplings out of the chest!")
print("If nothing happens the chest has too less materials!")
print("Press Enter to terminate process!")
while taking == true do
event = { os.pullEvent() }
if event[1] == "timer" and event[2] == delay then
refreshItemStack(1)
if turtle.getItemCount(1) < amountMinSaplings then
delay = os.startTimer(cancelTimer)
else
taking = false
end
elseif event[1] == "key" and event[2] == 28 then
print("Terminated by User!")
turtle.turnRight()
forward()
turtle.turnRight()
clearScreen()
os.shutdown()
end
end
print("Succesful!")
end
local function getBonemeal()
local taking = true
local delay = os.startTimer(cancelTimer)
print("Taking bonemeal out of the chest!")
print("If nothing happens the chest has too less materials!")
print("Press Enter to terminate process!")
while taking == true do
event = { os.pullEvent() }
if usebonemeal == true then
if event[1] == "timer" and event[2] == delay then
turtle.select(3)
turtle.suckUp()
turtle.select(2)
turtle.dropUp()
turtle.select(3)
turtle.dropUp()
turtle.select(2)
turtle.suckUp()
if turtle.getItemCount(3) > 0 then
print("!!!!!!!!!")
print("The bonemeal chest is full! Please take out some stacks, otherwise you lose items! The turtle will drop them!")
print("!!!!!!!!!")
turtle.select(3)
turtle.dropDown()
end
if turtle.getItemCount(2) < amountMinBonemeal then
delay = os.startTimer(cancelTimer)
else
taking = false
end
elseif event[1] == "key" and event[2] == 28 then
print("Terminated by User!")
turtle.turnRight()
forward()
turtle.turnRight()
clearScreen()
os.shutdown()
end
else
turtle.select(2)
turtle.dropUp()
taking = false
end
end
print("Successful!")
end
local function storeWood()
print("Storing wood in the chests!")
chestfull = true
while chestfull == true do
if usebonemeal == true then
for i=3,16 do
if turtle.getItemCount(i) > 0 then
turtle.select(i)
chestfull = turtle.drop()
end
end
else
for i=2,16 do
if turtle.getItemCount(i) > 0 then
turtle.select(i)
chestfull = turtle.drop()
end
end
end
chestfull = not chestfull
if chestfull == true and turtle.detectUp() == true then
print("Wood! Wood everywhere!!!")
print("Your wood chests are full!")
print("Try to add more vertical chests or take wood out of them.")
print("")
chopping = false
while turtle.detectDown() == false do
down()
end
turtle.turnRight()
end
if chestfull == true and turtle.detectUp() == false then
up()
print("This Chest is full!")
end
end
while turtle.detectDown() == false do
down()
end
print("Successful stored the wood!")
print("")
end
local function plantTree()
print("Planting saplings!")
moveForward(2)
turtle.turnRight()
turtle.select(1)
turtle.place()
turtle.turnLeft()
back()
turtle.place()
turtle.turnRight()
turtle.place()
turtle.turnLeft()
back()
turtle.place()
if usebonemeal == true then
while turtle.compare() == true and turtle.getItemCount(2) > 2 do
print("Fertilizing the tree with bonemeal!")
turtle.select(2)
turtle.place()
turtle.select(1)
sleep(bonemealFirstDelay)
if turtle.compare() == true then
print("Tree didnt grown with bonemeal!")
print("Will try again in two minutes...")
sleep(bonemealTimer)
end
end
else
print("Waiting for the tree to grow!")
print("Get some coffee this may take a while ;D")
while turtle.compare() == true do
os.sleep(5)
end
end
print("Successful planted new tree!")
print("")
end
local function getMaterials()
turtle.turnRight()
turtle.turnRight()
moveForward(distance)
turtle.select(3)
if usebonemeal then
turtle.dropDown(amountFurnaceWoodBonemeal)
else
turtle.dropDown(amountFurnaceWoodNoBonemeal)
end
storeWood()
turtle.turnRight()
if redstone.getInput("back") == false then
print("Shutdown by redstone signal!")
chopping = false
else
getCoal()
turtle.turnRight()
turtle.forward()
turtle.turnRight()
getSaplings()
getBonemeal()
turtle.turnLeft()
moveForward(distance-1)
end
end
local function cutWood()
print("Chopping down the tree!")
local height = 0
turtle.select(1)
turtle.dig()
forward()
turtle.dig()
while turtle.detectUp() do
turtle.digUp()
up()
turtle.dig()
height = height + 1
end
print("Reached the top of the tree!")
turtle.turnRight()
turtle.dig()
forward()
turtle.turnLeft()
turtle.dig()
while height > 0 do
turtle.digDown()
down()
turtle.dig()
height = height - 1
end
print("Successful chopped the tree!")
print("")
back()
turtle.turnLeft()
forward()
turtle.turnRight()
end
function chop()
if redstone.getInput("back") == true then
print("Starting the Fir Wood Chooper program!")
getCoal()
if turtle.getItemCount(3) > 0 or turtle.getItemCount(16) > 0 then
turtle.turnLeft()
storeWood()
turtle.turnRight()
end
turtle.turnRight()
forward()
turtle.turnRight()
if turtle.getItemCount(1) < amountMinSaplings then
getSaplings()
end
if turtle.getItemCount(2) < amountMinBonemeal and usebonemeal == true then
getBonemeal()
end
if turtle.getItemCount(2) > 0 and usebonemeal == false then
turtle.select(2)
turtle.dropUp()
end
turtle.turnRight()
forward()
turtle.turnRight()
turtle.turnRight()
moveForward(distance)
while chopping == true do
local needMaterials = false
if turtle.getFuelLevel() < 200 then
needMaterials = true
print("Have to refuel!")
end
if turtle.getItemCount(1) < amountMinSaplings then
needMaterials = true
print("Need more Saplings!")
end
if turtle.getItemCount(2) < amountMinBonemeal and usebonemeal then
needMaterials = true
print("Need more bonemeal!")
end
if usebonemeal and turtle.getItemCount(amountMaxWoodSlotBonemeal) > 0 then
needMaterials = true
print("Inventory almost full with wood!")
end
if usebonemeal == false and turtle.getItemCount(amountMaxWoodSlotNoBonemeal) > 0 then
needMaterials = true
print("Enough wood harvested!")
end
if needMaterials == true then
getMaterials()
end
if chopping == true then
plantTree()
cutWood()
end
end
else
print("No redstone signal, no wood!")
print("Be sure the Turtle is facing the coal chest and stays above the furnace!")
print("The redstone signal has to be in the back of the Turtle!")
end