View difference between Paste ID: 11uLUwB6 and Kngv6tWj
SHOW: | | - or go back to the newest paste.
1
--MENU
2
--VARIABLES
3
4
local version, savefile = "ULTIMATE WOOD CHOPPER BETA 0.9.5 B", "uwcvariables0.9.2"
5
local w,h = term.getSize()
6
local select, distance, turtleslot, menu = 1, 7, 1, 1
7
local running, chopping, usebonemeal = true, true, true
8
local savestate, runningProgram = 0, ""
9
local extremeMode = false
10
turtle.select(turtleslot)
11
12
--VARIABLES
13
cancelTimer = 2
14
bonemealTimer = 120
15
bonemealFirstDelay = 0
16
amountMaxWoodSlotBonemeal = 14
17
amountMaxWoodSlotNoBonemeal = 7
18
amountMinBonemeal = 8
19
amountMinSaplings = 17
20
amountMinFuelLevel = 1200
21
amountFurnaceWoodBonemeal = 16
22
amountFurnaceWoodNoBonemeal = 8
23
debugMaxHeight = 55
24
usebonemeal = true
25
persistence = true
26
amountbonemealtimes = 2
27
rednet.open("right")
28
29
30
function loadVariables()
31
 local file = fs.open(savefile,"r")
32
 cancelTimer = tonumber(file.readLine())
33
 bonemealTimer = tonumber(file.readLine())
34
 bonemealFirstDelay = tonumber(file.readLine())
35
 amountMaxWoodSlotBonemeal = tonumber(file.readLine())
36
 amountMaxWoodSlotNoBonemeal = tonumber(file.readLine())
37
 amountMinBonemeal = tonumber(file.readLine())
38
 amountMinSaplings = tonumber(file.readLine())
39
 amountMinFuelLevel = tonumber(file.readLine())
40
 amountFurnaceWoodBonemeal = tonumber(file.readLine())
41
 amountFurnaceWoodNoBonemeal = tonumber(file.readLine())
42
 debugMaxHeight = tonumber(file.readLine())
43
 local catchusebonemeal = file.readLine()
44
 if catchusebonemeal == "true" then usebonemeal = true else usebonemeal = false end
45
 distance = tonumber(file.readLine())
46
 local catchpersistence = file.readLine()
47
 if catchpersistence == "true" then persistence = true else persistence = false end
48
 amountbonemealtimes = tonumber(file.readLine())
49
 file.close()
50
end
51
52
function saveVariables()
53
 local file = fs.open(savefile,"w")
54
 file.writeLine(cancelTimer)
55
 file.writeLine(bonemealTimer)
56
 file.writeLine(bonemealFirstDelay)
57
 file.writeLine(amountMaxWoodSlotBonemeal)
58
 file.writeLine(amountMaxWoodSlotNoBonemeal)
59
 file.writeLine(amountMinBonemeal)
60
 file.writeLine(amountMinSaplings)
61
 file.writeLine(amountMinFuelLevel)
62
 file.writeLine(amountFurnaceWoodBonemeal)
63
 file.writeLine(amountFurnaceWoodNoBonemeal)
64
 file.writeLine(debugMaxHeight)
65
 file.writeLine(usebonemeal)
66
 file.writeLine(distance)
67
 file.writeLine(persistence)
68
 file.writeLine(amountbonemealtimes)
69
 for i=1,10 do
70
  file.writeLine("-1")
71
 end
72
 file.close()
73
end
74
75
--PRINT
76
77
function printCentered(str, ypos)
78
 term.setCursorPos(w/2 - #str/2, ypos)
79
 term.write(str)
80
end
81
82
function printRight(str, ypos)
83
 term.setCursorPos(w-#str, ypos)
84
 term.write(str)
85
end
86
87
function clearScreen()
88
 term.clear()
89
 term.setCursorPos(1,1)
90
 term.clear()
91
end
92
93
function drawHeader(title, line)
94
 printCentered(title, line)
95
 printCentered(string.rep("-", w), line+1)
96
end
97
98
function drawCopyright()
99
 printRight("by UNOBTANIUM", h)
100
end
101
102
103
104
--MENUS
105
106
local menupoint = {
107
{"Chop", "Turtle Interactions", "Build and Expand", "Help", "Credits", "Quit",nil},
108
{"Farm","Single Tree","Back",nil,nil,nil},
109
{"Standard Farm","Expanded Farm","Variables","Back",nil,nil,nil},
110
{"Build the standard farm","Expand the standard farm", "Build the expanded farm", "Add more chests","Back",nil,nil},
111
{"Standard Farm","Expanded Farm","Back",nil,nil,nil,nil},
112
{"Position","Dig needed space","Debug","Move Down","Back",nil,nil},
113
{"Help Programs","Help Interface","Back",nil,nil,nil,nil},
114
{"General 1x1 Tree","General 2x2 Tree","Back",nil,nil,nil,nil},
115
{"Movement","Actions","Control","Back",nil,nil,nil,nil},
116
{"Forward","Back","Up","Down","Turn Left","Turn Right","Back"},
117
{"Refuel","Dig","Select","Back",nil,nil,nil},
118
{"Up","Front","Down","Back",nil,nil,nil},
119
{"Bonemeal","Amount","Timer","Height","Slot","Persistence","Back"}
120
}
121
122
local menupointselected = {
123
{">> Chop <<", ">> Turtle Interactions <<", ">> Build and Expand <<", ">> Help <<", "> Credits <", "> Quit <",nil},
124
{">> Farm <<",">> Single Tree <<","> Back <",nil,nil,nil,nil},
125
{"> Standard Farm <","> Expanded Farm <",">> Variables <<","> Back <",nil,nil,nil},
126
{"> Build the standard farm <","> Expand the standard farm <", "> Build the expanded farm <","> Add more chests <","> Back <",nil,nil},
127
{"> Standard Farm <","> Expanded Farm <","> Back <",nil,nil,nil,nil},
128
{"> Position <","> Dig needed space <",">> Debug <<","> Move Down <","> Back <",nil,nil},
129
{">> Help Programs <<","> Help Interface <","> Back <",nil,nil,nil,nil},
130
{"> General 1x1 Tree <","> General 2x2 Tree <","> Back <",nil,nil,nil,nil},
131
{">> Movement <<",">> Actions <<","> Control <","> Back <",nil,nil,nil},
132
{"> Forward <","> Back <","> Up <","> Down <","> Turn Left <","> Turn Right <","> Back <"},
133
{"> Refuel <",">> Dig <<","> Select <","> Back <",nil,nil,nil},
134
{"> Up <","> Front <","> Down <","> Back <",nil,nil,nil},
135
{"> Bonemeal <","> Amount <","> Timer <","> Height <","> Slot <","> Persistence <","> Back <"}
136
}
137
138
local menupointnext = {
139
{2, 9, 4, 7, "credits", "quit"},
140
{3,8,1},
141
{"standard","expanded",13,2},
142
{"build","expand", "buildexpanded","expandchests",1},
143
{"debugstandard","debugexpanded",6},
144
{"position","digSpace",5,"godown",7},
145
{6,"helpinterface",1},
146
{"onebyone","twobytwo",2},
147
{10,11,"control",1},
148
{"forward","back","up","down","left","right",9},
149
{"refuel",12,"select",9},
150
{"digup","digfront","digdown",10},
151
{"varBonemeal","varAmount","varTimer","varHeight","varSlot","varPersistence",3}
152
}
153
154
function drawMenu()
155
 drawHeader(version, 1)
156
 if menu == 1 then
157
  drawCopyright()
158
 end
159
160
 for i=1,7 do
161
  if menupoint[menu][i] then
162
   if select == i then
163
    printCentered(menupointselected[menu][i], i+4)
164
   else
165
    printCentered(menupoint[menu][i], i+4)
166
   end
167
  end
168
 end
169
end
170
171
172
--RUN MENU
173
174
function runMenu()
175
 local showVariableHint = true
176
 while running do
177
  clearScreen()
178
  if menu == 13  and showVariableHint then
179
   UWCvariables()
180
   showVariableHint = false
181
  end
182
  drawMenu(menu)
183
184
  local id, key = os.pullEvent("key")
185
  if key == 200  or key == 17 then
186
   select = select-1
187
  end
188
  if key == 208 or key == 31 then
189
   select = select+1
190
  end
191
192
  if select == 0 then
193
   for i=7,1,-1 do
194
    if menupoint[menu][i] then
195
     select = i
196
     break
197
    end
198
   end
199
  end
200
201
  if not menupoint[menu][select] then
202
   select = 1
203
  end
204
205
  if key == 14 or key == 30 then
206
   for i=7,1,-1 do
207
    if menupoint[menu][i] then
208
     select = i
209
     break
210
    end
211
   end
212
   if type(menupointnext[menu][select]) == "string" then
213
    clearScreen()
214
    running = false
215
    break
216
   elseif type(menupointnext[menu][select]) == "number" then
217
    menu = menupointnext[menu][select]
218
    for i=7,1,-1 do
219
     if menupoint[menu][i] then
220
      select = i
221
      break
222
     end
223
    end
224
   end
225
  end
226
227
  clearScreen()
228
  if key == 28 or key == 32 then
229
   if type(menupointnext[menu][select]) == "string" then
230
    startProgram(menupointnext[menu][select])
231
   elseif type(menupointnext[menu][select]) == "number" then
232
    menu = menupointnext[menu][select]
233
    select = 1
234
   end
235
  end
236
 end
237
end
238
239
function startProgram(input)
240
 if input == "quit" then
241
  running = false
242
  runningProgram = ""
243
  saveVariables()
244
  saveSavePoint(0)
245
  return
246
 elseif input == "credits" then
247
  drawMenuCredits()
248
 elseif input == "standard" then
249
  distance = 7
250
  runningProgram = "standard"
251
  saveSavePoint(0)
252
  saveVariables()
253
  chop()
254
  runningProgram = ""
255
  saveVariables()
256
 elseif input == "expanded" then
257
  distance = 9
258
  runningProgram = "expanded"
259
  saveSavePoint(0)
260
  saveVariables()
261
  chop()
262
  runningProgram = "expanded"
263
  saveVariables()
264
 elseif input == "debugstandard" then
265
  distance = 7
266
  FWCdebug()
267
 elseif input == "debugexpanded" then
268
  distance = 9
269
  FWCdebug()
270
 elseif input == "build" then
271
  FWCbuild()
272
 elseif input == "buildexpanded" then
273
  UWCbuildexpanded()
274
 elseif input == "expand" then
275
  FWCexpand()
276
 elseif input == "helpinterface" then
277
  FWChelp()
278
 elseif input == "position" then
279
  FWCposition()
280
 elseif input == "expandchests" then
281
  FWCexpandchests()
282
 elseif input == "onebyone" then
283
  FWConebyone()
284
 elseif input == "twobytwo" then
285
  FWCtwobytwo()
286
 elseif input == "digSpace" then
287
  FWCdigSpace()
288
 elseif input == "forward" then
289
  turtle.forward()
290
 elseif input == "back" then
291
  turtle.back()
292
 elseif input == "up" then
293
  turtle.up()
294
 elseif input == "down" then
295
  turtle.down()
296
 elseif input == "left" then
297
  turtle.turnLeft()
298
 elseif input == "right" then
299
  turtle.turnRight()
300
 elseif input == "refuel" then
301
  turtle.refuel(1)
302
 elseif input == "select" then
303
  turtleslot = turtleslot + 1
304
  if turtleslot > 16 then turtleslot = 1 end
305
  turtle.select(turtleslot)
306
 elseif input == "digup" then
307
  turtle.digUp()
308
 elseif input == "digfront" then
309
  turtle.dig()
310
 elseif input == "digdown" then
311
  turtle.digDown()
312
 elseif input == "godown" then
313
  UWCgodown()
314
 elseif input == "varBonemeal" then
315
  varBonemeal()
316
 elseif input == "varAmount" then
317
  varAmount()
318
 elseif input == "varTimer" then
319
  varTimer()
320
 elseif input == "varHeight" then
321
  varHeight()
322
 elseif input == "varSlot" then
323
  varSlot()
324
 elseif input == "varPersistence" then
325
  varPersistence()
326
 elseif input == "control" then
327
  control()
328
 elseif input == "" then
329
  runMenu()
330
  return
331
 end
332
end
333
334
--LAST SESSION
335
336
337-
 sleep(0)
337+
338
 savestate = i
339
 local file = fs.open("uwcsavepoint","w")
340
 file.writeLine(savestate)
341
 file.writeLine(runningProgram)
342
 file.close()
343
end
344
345
function loadSavePoint()
346
 local file = fs.open("uwcsavepoint","r")
347
 savestate = tonumber(file.readLine())
348
 runningProgram = file.readLine()
349
 file.close()
350
end
351
352
function checkForLastSession()
353
 if not fs.exists("uwcsavepoint") then return end
354
 if not persistence then return end
355
 loadSavePoint()
356
 if savestate == 0 then
357
  startProgram(runningProgram)
358
  return
359
 end
360
 print("Turtle shutdown while it was working.")
361
 print("Starting last program")
362
 print("Stop persistence by pressing any key in the next 5 seconds.")
363
 local delay = os.startTimer(5)
364
 while true do
365
  local event = {os.pullEvent()}
366
  if event[1] == "timer" then
367
   break
368
  elseif event[1] == "char" then
369
   runningProgram = ""
370
   saveSavePoint(0)
371
   return
372
  end
373
 end
374
 print("Continue...")
375
 print("")
376
 while savestate > 0 do
377
  if savestate >= 8 then
378
   cutWood()
379
  end
380
  if savestate == 7 then
381
   turtle.back()
382
   saveSavePoint(2)
383
   turtle.down()
384
  end
385
  if savestate == 2 then
386
   saveSavePoint(4)
387
   turtle.turnLeft()
388
  end
389
  if savestate == 4 then
390
   saveSavePoint(1)
391
   turtle.turnLeft()
392
  end
393
  if savestate == 3 then
394
   saveSavePoint(1)
395
   turtle.turnRight()
396
  end
397
  if savestate == 6 then
398
   saveSavePoint(1)
399
   turtle.turnRight()
400
  end
401
  if savestate == 1 then
402
   local max = 1
403
   while not turtle.detect() and max < 15 do turtle.forward() max = max + 1 end
404
   if max == 15 then saveSavePoint(0) os.shutdown() end
405
   saveSavePoint(5)
406
  end
407
  if savestate == 5 then
408
   storeWood()
409
   saveSavePoint(0)
410
   turtle.turnRight()
411
  end
412
 end
413
 startProgram(runningProgram)
414
end
415
416
--CREDITS
417
418
function drawMenuCredits()
419
 drawHeader(version,1)
420
 printCentered("all nicknames from the CC forums!!",3)
421
 printCentered("- IDEA, CODEING & PUBLISHER -",5)
422
 printCentered("unobtanium",6)
423
 printCentered("- HELPING WITH CODING -",8)
424
 printCentered("theoriginalbit, Mtdj2, NitrogenFingers", 9)
425
 printCentered("- SPECIAL THANKS GOES TO -",11)
426
 printCentered("Hoppingmad9, xInDiGo, Seleck",12)
427
 printCentered("Permutation, PhilHibbs, DavEdward ",13)
428
 read()
429
 clearScreen()
430
 drawHeader(version,1)
431
 printCentered("- MENTIONABLES -",3)
432
 printCentered("HotGirlEAN, snoxx, steel_toed_boot,",4)
433
 printCentered("Zagi, Kylun, Kravyn, PhaxeNor, ughzug",5)
434
 printCentered("sjkeegs, atlas, Minithra, TheFan",6)
435
 printCentered("grumpysmurf, Quickslash78, lewanator1",7)
436
 printCentered("behedwin, TESTimonSHOOTER",8)
437
 printCentered("Kevironi, Fuzzlewhumper, Bigdavie",9)
438
 printCentered("Viproz, Bigjimmy12, bomanski, punchin",10)
439
 printCentered("oxgon, ahwtx, zilvar2k11",11)
440
 printCentered("The_Ianator, Coolkrieger3", 12)
441
 read()
442
 clearScreen()
443
 drawHeader(version,1)
444
 printCentered(version,1)
445
 printCentered("And last but not least",6)
446
 printCentered("You, the users and players :D",7)
447
 printCentered("Thank you everybody!!!", 10)
448
 read()
449
end
450
451
452
--ULTIMATE WOOD CHOPPER PROGRAMS
453
--VARIABLES
454
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
455
456
--MOVE FUNCTIONS
457
458
function forward()
459
 while not turtle.forward() do end
460
end
461
462
function back()
463
 while not turtle.back() do end
464
end
465
466
function up()
467
 while not turtle.up() do end
468
end
469
470
function down()
471
 while not turtle.down() do end
472
end
473
474
--MAIN CHOP PROGRAM FUNCTIONS
475
476
function moveForward(j)
477
 for i = 1,j do
478
  forward()
479
 end
480
end
481
482
function moveForwardRemove(j)
483
 for i = 1,j do
484
  turtle.dig()
485
  forward()
486
 end
487
end
488
489
function getCoal()
490
 local delay = os.startTimer(cancelTimer)
491
 print("Taking coal out of the chest!")
492
 print("If nothing happens the chest has too less materials!")
493
 print("Press Enter to terminate process!")
494
 
495
 while turtle.getFuelLevel() < amountMinFuelLevel do
496
  event = { os.pullEvent() }
497
  if event[1] == "timer" and event[2] == delay then
498
   turtle.select(16)
499
   turtle.suck()
500
   if turtle.getItemCount(16) > 0 then  
501
    turtle.refuel(math.ceil((amountMinFuelLevel - turtle.getFuelLevel())/80))
502
    turtle.drop()
503
    if turtle.getItemCount(16) > 0 then
504
     turtle.select(16)
505
     turtle.refuel()
506
    end
507
    if turtle.getFuelLevel() < amountMinFuelLevel then
508
     delay = os.startTimer(2)
509
    end
510
   else 
511
    delay = os.startTimer(cancelTimer)
512
   end
513
  elseif event[1] == "key" and event[2] == 28 then
514
   print("Terminated by User!")
515
   clearScreen()
516
   runningProgram = ""
517
   saveSavePoint(0)
518
   os.reboot()
519
  end
520
 end
521
 print("Succesful!")
522
end
523
524
function getSaplings()
525
 local taking = true
526
 local delay = os.startTimer(cancelTimer)
527
 print("Taking saplings out of the chest!")
528
 print("If nothing happens the chest has too less materials!")
529
 print("Press Enter to terminate process!")
530
531
 while taking == true do
532
  event = { os.pullEvent() }
533
  if event[1] == "timer" and event[2] == delay then
534
   if turtle.getItemCount(1) > 0 then
535
    if turtle.getItemCount(2) > 0 then
536
     turtle.select(1)
537
     turtle.suck()
538
     if turtle.getItemCount(3) > 0 then
539
      turtle.select(3)
540
      turtle.drop()
541
     end
542
    else
543
     turtle.select(1)
544
     turtle.suck()
545
     if turtle.getItemCount(2) > 0 then
546
      turtle.select(2)
547
      turtle.drop()
548
     end    
549
    end
550
   else
551
    turtle.select(1)
552
    turtle.suck()
553
   end
554
   if turtle.getItemCount(3) > 0 then
555
    print("!!!!!!!!!")
556
    print("The sapling chest is full! Please take out some stacks, otherwise you lose items! The turtle will drop them!")
557
    print("!!!!!!!!!")
558
    turtle.select(3)
559
    turtle.dropDown()
560
   end
561
   if turtle.getItemCount(1) < amountMinSaplings then
562
    delay = os.startTimer(cancelTimer)
563
   else
564
    taking = false
565
   end
566
  elseif event[1] == "key" and event[2] == 28 then
567
   print("Terminated by User!")
568
   turtle.turnRight()
569
   forward()
570
   turtle.turnRight()
571
   clearScreen()
572
   runningProgram = ""
573
   saveSavePoint(0)
574
   os.reboot()
575
  end
576
 end
577
 print("Succesful!")
578
end
579
580
function getBonemeal()
581
 local taking = true
582
 local delay = os.startTimer(cancelTimer)
583
 print("Taking bonemeal out of the chest!")
584
 print("If nothing happens the chest has too less materials!")
585
 print("Press Enter to terminate process!")
586
587
 while taking == true do
588
  event = { os.pullEvent() }
589
  if usebonemeal == true then
590
   if event[1] == "timer" and event[2] == delay then
591
   if turtle.getItemCount(2) > 0 then
592
    turtle.select(2)
593
    turtle.suckUp()
594
    if turtle.getItemCount(3) > 0 then
595
     turtle.select(3)
596
     turtle.dropUp()
597
    end
598
   else
599
    turtle.select(2)
600
    turtle.suckUp()
601
   end
602
    if turtle.getItemCount(3) > 0 then
603
     print("!!!!!!!!!")
604
     print("The bonemeal chest is full! Please take out some stacks, otherwise you lose items! The turtle will drop them!")
605
     print("!!!!!!!!!")
606
     turtle.select(3)
607
     turtle.dropDown()
608
    end
609
    if turtle.getItemCount(2) < amountMinBonemeal then
610
     delay = os.startTimer(cancelTimer)
611
    else
612
     taking = false
613
    end
614
   elseif event[1] == "key" and event[2] == 28 then
615
    print("Terminated by User!")
616
    turtle.turnRight()
617
    forward()
618
    turtle.turnRight()
619
    clearScreen()
620
    runningProgram = ""
621
    saveSavePoint(0)
622
    os.reboot()
623
   end
624
  else
625
   turtle.select(2)
626
   turtle.dropUp()
627
   taking = false
628
  end
629
 end
630
 print("Successful!")
631
end
632
633
function storeWood()
634
 print("Storing wood in the chests!")
635
 chestfull = true
636
 while chestfull == true do
637
  if usebonemeal == true then
638
   for i=3,16 do
639
    if turtle.getItemCount(i) > 0 then
640
     turtle.select(i)
641
     chestfull = turtle.drop()
642
    end
643
   end
644
  else
645
   for i=2,16 do
646
    if turtle.getItemCount(i) > 0 then
647
     turtle.select(i)
648
     chestfull = turtle.drop()
649
    end
650
   end
651
  end
652
653
  chestfull = not chestfull
654
   
655
  if chestfull == true and turtle.detectUp() == true then
656
   print("Wood! Wood everywhere!!!")
657
   print("Your wood chests are full!")
658
   print("Try to add more vertical chests or take wood out of them.")
659
   print("")
660
   chopping = false
661
   while turtle.detectDown() == false do
662
    down()
663
   end
664
   turtle.turnRight()
665
  end
666
667
  if chestfull == true and turtle.detectUp() == false then
668
   up()
669
   print("This Chest is full!")
670
  end
671
672
 end
673
 
674
 while turtle.detectDown() == false do
675
 down()
676
 end
677
 
678
 print("Successful stored the wood!")
679
 print("")
680
end
681
682
function treeGrew()
683
 turtle.select(1)
684
 if turtle.compare() then
685
  return false
686
 else
687
  return true
688
 end
689
end
690
691
function plantTree()
692
 if turtle.detect() and treeGrew() then print("There is allready a tree!") return true end
693
 turtle.select(1)
694
 if not turtle.detect() then
695
  print("Planting saplings!")
696
  turtle.dig()
697
  forward()
698
  turtle.dig()
699
  forward()
700
  saveSavePoint(6)
701
  turtle.turnRight()
702
  turtle.dig()
703
  while not turtle.place() do sleep(0.5) print("Failed placing a sapling!") end
704
  saveSavePoint(2)
705
  turtle.turnLeft()
706
  back()
707
  while not turtle.place() do sleep(0.5) print("Failed placing a sapling!") end
708
  saveSavePoint(6)
709
  turtle.turnRight()
710
  turtle.dig()
711
  while not turtle.place() do sleep(0.5) print("Failed placing a sapling!") end
712
  saveSavePoint(2)
713
  turtle.turnLeft()
714
  back()
715
  while not turtle.place() do sleep(0.5) print("Failed placing a sapling!") end
716
  if usebonemeal then
717
   sleep(bonemealFirstDelay + 0.2)
718
  end
719
 end
720
 while true do
721
  if usebonemeal then
722
   if turtle.getItemCount(2) <= amountbonemealtimes + 1 then
723
    print("Ran out of bonemeal!")
724
    print("")
725
    return false
726
   end
727
   print("Fertilizing the sapling with bonemeal!")
728
   turtle.select(2)
729
   local amountPlaced = 0
730
   for i=1,amountbonemealtimes do
731
    if turtle.place() then
732
     amountPlaced = amountPlaced + 1
733
    end
734
    sleep(0.6)
735
   end
736
   print("Fertilized the sapling ".. amountPlaced .." times!")
737
  end
738
  turtle.select(1)
739
740
  if not treeGrew() then
741
   print("Tree didnt grew yet!")
742
   if usebonemeal then
743
    print("Bonemealing again in " .. bonemealTimer .." seconds...")
744
   else
745
    print("Check again in " .. bonemealTimer .." seconds...")
746
   end
747
   back()
748
   sleep(bonemealTimer)
749
   forward()
750
  else
751-
   print("Successful planted new tree!")
751+
   print("Successfully planted new tree!")
752
   print("")
753
   return true
754
  end
755
 end
756
end
757
758
759
function getMaterials()
760
 saveSavePoint(4)
761
 turtle.turnLeft()
762
 saveSavePoint(1)
763
 turtle.turnLeft()
764
 moveForward(distance)
765
 
766
 turtle.select(3)
767
 if usebonemeal then
768
  turtle.dropDown(amountFurnaceWoodBonemeal)
769
 else
770
  turtle.dropDown(amountFurnaceWoodNoBonemeal)
771
 end
772
 saveSavePoint(5)
773
 storeWood()
774
775
 saveSavePoint(0)
776
 turtle.turnRight()
777
    
778
 if redstone.getInput("back") == false then
779
  print("Shutdown by redstone signal!")
780
  chopping = false
781
  runningProgram = ""
782
  saveSavePoint(0)
783
 else
784
  getCoal()
785
  saveSavePoint(2)
786
  turtle.turnRight()
787
  turtle.forward()
788
  saveSavePoint(3)
789
  turtle.turnRight()  
790
  getSaplings()
791
  getBonemeal()
792
  saveSavePoint(2)
793
  turtle.turnLeft()
794
  moveForward(distance-1)
795
 end
796
end
797
798
function chopUp()
799
 turtle.dig()
800
 while turtle.detectUp() do
801
  saveSavePoint(110)
802
  turtle.digUp()
803
  saveSavePoint(102)
804
  up()
805
  turtle.dig()
806
 end
807
end
808
809
function chopDown()
810
 turtle.dig()
811
 while turtle.detectDown() do
812
  saveSavePoint(111)
813
  turtle.digDown()
814
  saveSavePoint(103)
815
  down()
816
  turtle.dig()
817
 end
818
end
819
820
function cutWood()
821
 turtle.select(1)
822
 if savestate == 2 then
823
  turtle.dig()
824
  saveSavePoint(100)
825
  forward()
826
 end
827
 if savestate == 100 then
828
  if turtle.detectUp() then
829
   print("Chopping down the tree!")
830
   saveSavePoint(101)
831
   turtle.turnRight()
832
  else
833
   saveSavePoint(2)
834
   back()
835
   print("ERROR!!! No tree above!")
836
   print("Prevented: Digging down to bedrock!")
837
   return
838
  end
839
 end
840
 if savestate == 101 then
841
  turtle.dig()
842
  saveSavePoint(102)
843
  turtle.turnLeft()
844
 end
845
 if savestate == 110 then
846
  saveSavePoint(102)
847
  up()
848
 end
849
 if savestate == 102 then
850
  chopUp()
851
  saveSavePoint(8)
852
  turtle.turnRight()
853
 end
854
 print("Reached the top of the tree!")
855
 if savestate == 8 then
856
  turtle.dig()
857
  saveSavePoint(9)
858
  forward()
859
 end
860
 if savestate == 9 then
861
  saveSavePoint(103)
862
  turtle.turnLeft()
863
 end
864
 if savestate == 111 then
865
  saveSavePoint(103)
866
  down()
867
 end
868
 if savestate == 103 then
869
  chopDown()
870
  saveSavePoint(104)
871
  turtle.dig()
872
 end
873
 if savestate == 104 then
874
  saveSavePoint(105)
875
  down()
876
 end
877
 if savestate == 105 then
878
  saveSavePoint(106)
879
  turtle.dig()
880
 end
881
 if savestate == 106 then
882
  saveSavePoint(10)
883
  back()
884
 end
885
 print("Successful chopped the tree!")
886
rednet.broadcast("clear")
887
 print("")
888
 if savestate == 10 then
889
  saveSavePoint(11)
890
  turtle.turnLeft()
891
 end
892
 if savestate == 11 then
893
  saveSavePoint(12)
894
  forward()
895
 end
896
 if savestate == 12 then
897
  saveSavePoint(2)
898
  turtle.turnRight()
899
 end
900
end
901
902
903
904
905
906
function chop()
907
 if redstone.getInput("back") == true then
908
  saveSavePoint(0)
909
  print("Starting the Fir Wood Chooper program!")
910
  getCoal()
911
  if turtle.getItemCount(3) > 0 or turtle.getItemCount(16) > 0 then
912
   saveSavePoint(1)
913
   turtle.turnLeft()
914
   storeWood()
915
   saveSavePoint(0)
916
   turtle.turnRight()
917
  end
918
  saveSavePoint(2)
919
  turtle.turnRight()
920
  forward()
921
  saveSavePoint(3)
922
  turtle.turnRight()
923
  if turtle.getItemCount(1) < amountMinSaplings then
924
   getSaplings()
925
  end
926
  if turtle.getItemCount(2) < amountMinBonemeal and usebonemeal == true then
927
   getBonemeal()
928
  end
929
  if turtle.getItemCount(2) > 0 and usebonemeal == false then
930
   turtle.select(2)
931
   turtle.dropUp()
932
  end
933
  saveSavePoint(1)
934
  turtle.turnRight()
935
  forward()
936
  saveSavePoint(0)
937
  turtle.turnRight()
938
  saveSavePoint(2)
939
  turtle.turnRight()
940
  moveForward(distance)
941
  
942
  while chopping == true do
943
   local needMaterials = false
944
   if turtle.getFuelLevel() < 200 then
945
    needMaterials = true
946
    print("Have to refuel!")
947
   end
948
   if turtle.getItemCount(1) < amountMinSaplings then
949
    needMaterials = true
950
    print("Need more Saplings!")
951
   end
952
   if usebonemeal and turtle.getItemCount(2) < amountMinBonemeal then
953
    needMaterials = true
954
    print("Need more bonemeal!")
955
   end
956
   if usebonemeal and turtle.getItemCount(amountMaxWoodSlotBonemeal) > 0 then
957
    needMaterials = true
958
    print("Enough wood harvested!")
959
   elseif not usebonemeal and turtle.getItemCount(amountMaxWoodSlotNoBonemeal) > 0 then
960
    needMaterials = true
961
    print("Enough wood harvested!")
962
   end
963
   if needMaterials then
964
    getMaterials()
965
   end
966
   if chopping then
967
    if plantTree() then
968
     cutWood()
969
    end
970
   end
971
   sleep(0)
972
  end
973
 else
974
  runningProgram = ""
975
  saveSavePoint(0)
976
  print("No redstone signal, no wood!")
977
  print("Be sure the Turtle is facing the coal chest and stays above the furnace!")
978
  print("The redstone signal has to be in the back of the Turtle!")
979
 end
980
 print("Press Enter to get back into the menu...")
981
 read()
982
 chopping = true
983
end
984
985
--MAIN DEBUG FUNCTIONS
986
987
function FWCdebug()
988
 getCoal()
989
 turtle.turnRight()
990
 moveForward(distance)
991
 local height = 0
992
 turtle.select(1)
993
 turtle.dig()
994
 forward()
995
 turtle.dig()
996
 while not turtle.detectUp() and height < debugMaxHeight do
997
  turtle.up()
998
  height = height + 1
999
 end
1000
 turtle.dig()
1001
 while turtle.detectUp() do
1002
  turtle.digUp()
1003
  turtle.up()
1004
  turtle.dig()
1005
  height = height + 1
1006
 end
1007
 turtle.turnRight()
1008
 turtle.dig()
1009
 forward()
1010
 turtle.turnLeft()
1011
 turtle.dig()
1012
 while height > 0 do
1013
  turtle.digDown()
1014
  down()
1015
  turtle.dig()
1016
  height = height - 1
1017
 end
1018
 back()
1019
 turtle.turnLeft()
1020
 forward()
1021
 turtle.turnLeft()
1022
 moveForward(distance)
1023
 turtle.turnRight()
1024
 print("Debug finished! Please take the wood out of the inventory!")
1025
 print("Press Enter to get back into the menu!")
1026
 read()
1027
end
1028
1029
-- MOVEMENT FUNCTIONS
1030
1031
function dbp(j) -- dig down, place down, back (dig), place
1032
 j = j or 1
1033
 for i=1,j do
1034
  turtle.digDown()
1035
  turtle.placeDown()
1036
  db()
1037
  turtle.place()
1038
 end
1039
end
1040
1041
function lb() -- left, back (dig)
1042
 turtle.turnLeft()
1043
 db()
1044
end
1045
1046
function db() -- back (dig)
1047
 if not turtle.back() then
1048
  turtle.turnLeft()
1049
  turtle.turnLeft()
1050
  turtle.dig()
1051
  turtle.forward()
1052
  turtle.turnLeft()
1053
  turtle.turnLeft()
1054
 end
1055
end
1056
1057
function bp(j) -- back (dig), place
1058
 j = j or 1
1059
 for i=1,j do
1060
  db()
1061
  turtle.place()
1062
 end
1063
end
1064
1065
function checkBlocks()
1066
 if turtle.getItemCount(blockslot) == 0 and blockslot < 10 then
1067
  blockslot = blockslot + 1
1068
  turtle.select(blockslot)
1069
 end
1070
end
1071
1072
function fd(j) -- forward (dig)
1073
 j = j or 1
1074
 for i=1, j do
1075
  if turtle.detect() then
1076
   turtle.dig()
1077
  end
1078
 turtle.forward()
1079
 end
1080
end
1081
1082
function fdown(j) -- forward, placeDown (digDown)
1083
 j = j or 1
1084
 for i=1,j do
1085
  if not turtle.forward() then
1086
   turtle.dig()
1087
   turtle.forward()
1088
  end
1089
  if turtle.detectDown() then
1090
   turtle.digDown()
1091
  end
1092
  turtle.placeDown()
1093
 end
1094
end
1095
1096
function fde(j,check) -- forward (dig), digUp, digDown, checkBlocks, placeDown
1097
 j = j or 1
1098
 check = check or true
1099
 for i=1,j do
1100
  dfd(1)
1101
  if check then
1102
   checkBlocks()
1103
  end
1104
  turtle.placeDown()
1105
 end
1106
end
1107
1108
function dfd(j) -- forward (dig), digUp, digDown
1109
 j = j or 1
1110
 for i=1,j do
1111
  df(1)
1112
  turtle.digDown()
1113
 end
1114
end
1115
1116
function df(j) -- forward (dig), digUp
1117
 j = j or 1
1118
 for i=1,j do
1119
  if turtle.detect() then
1120
   turtle.dig()
1121
  end
1122
  forward()
1123
  turtle.digUp()
1124
 end
1125
end
1126
1127
function dd() -- digDown, down
1128
 turtle.digDown() 
1129
 turtle.down()
1130
end
1131
1132
function du() -- digUp, up
1133
 turtle.digUp()
1134
 turtle.up()
1135
end
1136
1137
1138
1139
1140
1141
-- BUILD FUNCTIONS
1142
1143
function buildBase(standard)
1144
 turtle.select(stone3)
1145
 if not standard then
1146
  entrance()
1147
  dd()
1148
  dd()
1149
  moveForward(2)
1150
  turtle.dig()
1151
  turtle.place()
1152
  turtle.turnLeft()
1153
  db()
1154
  turtle.place()
1155
  du()
1156
  du()
1157
  turtle.turnLeft()
1158
  turtle.turnLeft()
1159
 end
1160
 turtle.placeDown()
1161
 turtle.turnLeft()
1162
 turtle.select(chest)
1163
 turtle.place()
1164
 turtle.select(sapling)
1165
 turtle.drop()
1166
 turtle.turnRight()
1167
 turtle.select(chest)
1168
 turtle.placeUp()
1169
 turtle.select(bonemeal)
1170
 turtle.dropUp()
1171
 forward()
1172
 turtle.select(chest)
1173
 turtle.place()
1174
 du()
1175
 turtle.place()
1176
 du()
1177
 turtle.place()
1178
 turtle.select(stone3)
1179
 turtle.placeUp()
1180
 
1181
 dd()
1182
 dd()
1183
 dd()
1184
 turtle.turnRight()
1185
 turtle.select(woodenpipe)
1186
 turtle.place()
1187
 turtle.turnLeft()
1188
 dd()
1189
 turtle.select(furnace)
1190
 turtle.placeUp()
1191
 turtle.select(coal)
1192
 turtle.dropUp(1)
1193
 turtle.select(ironpipe)
1194
 turtle.dig()
1195
 turtle.place()
1196
 lb()
1197
 turtle.select(pipe)
1198
 turtle.place()
1199
 turtle.turnLeft()
1200
 db()
1201
 turtle.select(goldpipe)
1202
 turtle.place()
1203
 du()
1204
 du()
1205
 turtle.select(chest)
1206
 turtle.place()
1207
 turtle.select(coal)
1208
 turtle.drop(1)
1209
 turtle.select(engine)
1210
 turtle.placeDown()
1211
 db()
1212
 turtle.select(stone3)
1213
 turtle.placeDown()
1214
 lb()
1215
 turtle.select(lever)
1216
 turtle.place()
1217
 db()
1218
 turtle.turnRight()
1219
 moveForward(2)
1220
 dd()
1221
 turtle.select(pipe)
1222
 turtle.dig()
1223
 turtle.place()
1224
 dd()
1225
 turtle.dig()
1226
 turtle.place()
1227
 dd()
1228
 if standard then
1229
  fd(2)
1230
  turtle.select(obsidianpipe)
1231
  turtle.place()
1232
  db()
1233
  turtle.select(pipe)
1234
  turtle.place()
1235
  db()
1236
 end
1237
 turtle.place()
1238
 
1239
 turtle.turnLeft()
1240
 du()
1241
 du()
1242
 du()
1243
 turtle.select(stone3)
1244
 turtle.placeDown()
1245
 fd()
1246
 turtle.turnRight()
1247
 turtle.turnRight()
1248
 turtle.select(lever)
1249
 turtle.place()
1250
 turtle.turnRight()
1251
 turtle.turnRight() 
1252
end
1253
1254
function entrance()
1255
 moveForward(2)
1256
 turtle.turnRight()
1257
 fd()
1258
 turtle.placeUp()
1259
 dbp(1)
1260
 turtle.placeUp()
1261
 turtle.digDown()
1262
 turtle.placeDown()
1263
 db()
1264
 turtle.placeUp()
1265
 dbp(1)
1266
end
1267
1268
1269
function FWCbuild()
1270
 if turtle.detectDown() then
1271
  print("There is a block underneath the turtle.")
1272
  print("Be sure you have free space under the turtle.")
1273
  print("Press Enter to get back to the menu.")
1274
  read()
1275
  return false
1276
 end
1277
 turtle.select(coal)
1278
 for i=1,fuel do
1279
  while not turtle.refuel(1) do print("Refuel didnt worked.") sleep(1) end
1280
 end
1281
 turtle.select(stone1)
1282
 entrance()
1283
 dd()
1284
 dd()
1285
 turtle.turnLeft()
1286
 turtle.turnLeft()
1287
 fd()
1288
1289
 dbp(4)
1290
 turtle.select(stone1)
1291
 bp(1)
1292
 
1293
 dbp(3)
1294
 
1295
 lb()
1296
 dbp(2)
1297
 bp(8)
1298
 
1299
 lb()
1300
 bp(8)
1301
 
1302
 lb()
1303
 bp(8)
1304
 dbp(1)
1305
 turtle.digDown()
1306
 turtle.placeDown()
1307
 turtle.turnLeft()
1308
 bp(1) 
1309
 
1310
 turtle.turnRight()
1311
 turtle.turnRight()
1312
 dd()
1313
 turtle.digDown()
1314
 turtle.placeDown()
1315
 fde(7,false)
1316
 turtle.turnLeft()
1317
 fde(1,false)
1318
 turtle.turnLeft()
1319
 turtle.select(stone1)
1320
 fde(7,false)
1321
 
1322
 turtle.select(stone2)
1323
 turtle.turnRight()
1324
 du()
1325
 fdown(1)
1326
 for i = 1,4 do
1327
  fdown(7)
1328
  turtle.turnRight()
1329
  fdown(1)
1330
  turtle.turnRight()
1331
  fdown(7)
1332
  if i < 4 then
1333
   turtle.turnLeft()
1334
   fdown(1)
1335
   turtle.turnLeft()
1336
  end
1337
 end
1338
 
1339
 turtle.select(stone3)
1340
 du()
1341
 du()
1342
 turtle.turnRight()
1343
 moveForward(3)
1344
 turtle.turnRight()
1345
 moveForward(2)
1346
 turtle.select(dirt)
1347
 fdown(2)
1348
 turtle.turnLeft()
1349
 fdown(1)
1350
 turtle.turnLeft()
1351
 fdown(1)
1352
 moveForward(7)
1353
1354
 buildBase(true)
1355
 
1356
 print("Finally set up the farm! Enjoy!")
1357
 print("Flip the lever for the redstone engine.")
1358
 print("")
1359
 print("Press Enter to get back into the menu!")
1360
 read()
1361
end
1362
1363
-- EXPAND FUNCTIONS
1364
1365
function destroy()
1366
 turtle.turnRight()
1367
 moveForward(3)
1368
 dd()
1369
 dd()
1370
 dd()
1371
 turtle.turnRight()
1372
 turtle.select(obsidianpipeexpand)
1373
 fd()
1374
 turtle.turnRight()
1375
 turtle.select(pipeexpand)
1376
 fd()
1377
 turtle.select(blockslot)
1378
 turtle.turnLeft()
1379
 df(3)
1380
 turtle.select(16)
1381
 turtle.dig()
1382
 turtle.forward()
1383
 turtle.select(blockslot)
1384
 turtle.turnLeft()
1385
 du()
1386
 dfd(2)
1387
 df(9)
1388
 turtle.turnLeft()
1389
 df(9)
1390
 turtle.turnLeft()
1391
 df(8)
1392
 dfd(2)
1393
 if turtle.detectDown() then
1394
  turtle.select(16)
1395
  turtle.digDown()
1396
  turtle.select(blockslot)
1397
 end
1398
 dd()
1399
 if turtle.detectDown() then
1400
  turtle.select(16)
1401
  turtle.digDown()
1402
  turtle.select(blockslot)
1403
 end
1404
 dd()
1405
 turtle.turnLeft()
1406
 df(8)
1407
 turtle.turnLeft()
1408
 df(1)
1409
 turtle.turnLeft()
1410
 df(7)
1411
 turtle.turnRight()
1412
 du()
1413
 df(1)
1414
 for i=1,4 do
1415
  df(7)
1416
  turtle.turnRight()
1417
  df(1)
1418
  turtle.turnRight()
1419
  df(7)
1420
  if i < 4 then
1421
   turtle.turnLeft()
1422
   fd()
1423
   turtle.turnLeft()
1424
  end
1425
 end
1426
 forward()
1427
end
1428
1429
function layout(expanding)
1430
 turtle.select(blockslot)
1431
 if expanding then
1432
  forward()
1433
  du()
1434
  du()
1435
  du()
1436
  fd()
1437
  turtle.turnLeft()
1438
  db()
1439
  db()
1440
 end
1441
 turtle.digDown()
1442
 turtle.placeDown()
1443
 fde(7)
1444
 for i=1,3 do
1445
  turtle.turnLeft()
1446
  fde(7)
1447
  df()
1448
  dd()
1449
  turtle.digDown()
1450
  turtle.placeDown()
1451
  fde(1)
1452
  du()
1453
  db()
1454
  turtle.digDown()
1455
  turtle.placeDown()
1456
  fde(9)
1457
 end
1458
 turtle.turnLeft()
1459
 fde(6)
1460
 turtle.turnLeft()
1461
 df()
1462
 turtle.turnRight()
1463
 for i=1,10 do
1464
  df()
1465
 end
1466
 turtle.turnLeft()
1467
 for i=1,8 do
1468
  df()
1469
 end
1470
end
1471
1472
function corners()
1473
 dd()
1474
 for i=1,4 do
1475
  fde(7)
1476
  turtle.turnLeft()
1477
  fde(6)
1478
  turtle.turnLeft()
1479
  df()
1480
  turtle.turnLeft()
1481
  fde(5)
1482
  turtle.turnRight()
1483
  fde(4)
1484
  turtle.turnRight()
1485
  df()
1486
  turtle.turnRight()
1487
  fde(3)
1488
  turtle.turnLeft()
1489
  fde(2)
1490
  db()
1491
  turtle.turnLeft()
1492
  fde(1)
1493
  turtle.turnRight()
1494
  turtle.turnRight()
1495
  for i=1,3 do
1496
   df()
1497
  end
1498
  turtle.turnLeft()
1499
  for i=1,5 do
1500
   df()
1501
  end
1502
 end
1503
end
1504
1505
function lines(j)
1506
 fde(j)
1507
 db()
1508
 turtle.turnLeft()
1509
 fde(1)
1510
 turtle.turnLeft()
1511
 fde(j-2)
1512
 if j > 4 then
1513
  db()
1514
  turtle.turnRight()
1515
  fde(1)
1516
  turtle.turnRight()
1517
  lines(j-4)
1518
 end
1519
end
1520
1521
function plateau()
1522
 dd()
1523
 db()
1524
 turtle.digDown()
1525
 turtle.placeDown()
1526
 turtle.turnLeft()
1527
 lines(15)
1528
 turtle.turnLeft()
1529
  for i=1,8 do
1530
   df()
1531
  end
1532
 turtle.turnLeft()
1533
  for i=1,8 do
1534
   df()
1535
  end
1536
 turtle.turnRight()
1537
 turtle.turnRight()
1538
 turtle.digDown()
1539
 turtle.placeDown()
1540
 lines(15)
1541
end
1542
1543
function pipeAndDirt()
1544
 db()
1545
 turtle.turnLeft()
1546
 moveForward(9)
1547
 turtle.select(dirtexpand)
1548
 turtle.digUp()
1549
 fd()
1550
 turtle.digUp()
1551
 turtle.turnRight()
1552
 fd()
1553
 turtle.digUp()
1554
 turtle.turnRight()
1555
 fd()
1556
 turtle.digUp()
1557
 fd()
1558
 turtle.placeUp()
1559
 fd()
1560
 turtle.placeUp()
1561
 turtle.turnRight()
1562
 fd()
1563
 turtle.placeUp()
1564
 turtle.turnRight()
1565
 fd()
1566
 turtle.placeUp()
1567
 dd()
1568
 turtle.select(obsidianpipeexpand)
1569
 turtle.placeUp()
1570
 dd()
1571
 turtle.select(pipeexpand)
1572
 turtle.placeUp()
1573
 for i=1,10 do
1574
  fd()
1575
  turtle.turnLeft()
1576
  turtle.turnLeft()
1577
  turtle.place()
1578
  turtle.turnLeft()
1579
  turtle.turnLeft()
1580
 end
1581
 fd()
1582
 for i=1,5 do
1583
  du()
1584
 end
1585
 db()
1586
 turtle.turnRight()
1587
 fd()
1588
 dd()
1589
end
1590
1591
-- EXPAND
1592
1593
function FWCexpand()
1594
 print("Expanding farm!")
1595
 print("The refueling needs around 8 coal!")
1596
 while turtle.getFuelLevel() < 600 do
1597
  turtle.select(coal)
1598
  if turtle.refuel(1) then
1599
   print("Refueling!")
1600
  else
1601
   print("Didn't refueled!")
1602
   sleep(1)
1603
  end
1604
 end
1605
 blockslot = 5
1606
 destroy()
1607
 layout(true)
1608
 corners()
1609
 plateau()
1610
 pipeAndDirt()
1611
 print("Finished!")
1612
 print("Press Enter to get back into the menu!")
1613
 read()
1614
end
1615
1616
-- UWC BUILD EXPANDED FARM RIGHT AWAY
1617
1618
function UWCbuildexpanded()
1619
 local doesItDig = true
1620
 if turtle.detectDown() then
1621
  print("There is a block underneath the turtle.")
1622
 end
1623
 print("Do you want the turtle to dig the needed space for you?")
1624
 print("Y/N")
1625
 local id, key = os.pullEvent("key")
1626
 if key == 49  then
1627
  doesItDig = false
1628
  print("Start building!")
1629
  turtle.turnLeft()
1630
  turtle.turnLeft()
1631
 end
1632
 if doesItDig then
1633
  turtle.select(1)
1634
  print("Place a charcoal in slot 1 (top left, the selected one)")
1635
  while turtle.getItemCount(1) == 0 do sleep(1) end
1636
  print("Start building and digging!")
1637
  turtle.refuel(1)
1638
  sleep(1)
1639
  du()
1640
  db()
1641
  db()
1642
  dd()
1643
  UWCdigBaseSpace()
1644
  forward()
1645
  turtle.turnLeft()
1646
  forward()
1647
  for i=1,16 do
1648
   if turtle.getItemCount(i) > 0 then
1649
    turtle.select(i)
1650
    turtle.drop()
1651
   end
1652
  end 
1653
 end
1654
 sleep(1)
1655
 for i=1,16 do
1656
  turtle.select(i)
1657
  turtle.suck()
1658
 end
1659
 turtle.select(1)
1660
 turtle.refuel(8)
1661
 turtle.turnLeft()
1662
 turtle.turnLeft()
1663
 buildBase(false)
1664
 turtle.turnLeft()
1665
 for i=4,5 do
1666
  turtle.select(i)
1667
  turtle.transferTo(i-2)
1668
 end
1669
 turtle.select(8)
1670
 turtle.transferTo(4)
1671
 for i=13,15 do
1672
  turtle.select(i)
1673
  turtle.transferTo(i-8)
1674
 end
1675
 turtle.select(5)
1676
 for i=1,3 do
1677
  turtle.suck()
1678
 end
1679
 turtle.turnLeft()
1680
 turtle.turnLeft()
1681
 moveForward(3)
1682
 turtle.turnRight()
1683
 moveForward(2)
1684
 turtle.turnRight()
1685
 fd()
1686
 turtle.turnLeft()
1687
 blockslot = 5
1688
 layout(false)
1689
 corners()
1690
 plateau()
1691
 pipeAndDirt()
1692
 print("Finished building the expanded farm!")
1693
 print("Please take ALL items out of the inventory!")
1694
 print("Press Enter to get back into the menu!")
1695
 read()
1696
end
1697
1698
1699
--FWChelp 77777777777777777777777777777777777777777
1700
1701
function FWChelp()
1702
 print("Welcome to the UWC Help Interface!")
1703
 print("If you have any question, suggestions, bugs or feedback, let me know: Type")
1704
 print("computercraft forum ultimate wood chopper")
1705
 print("in Google and write a post or PM at me ;D")
1706
 read()
1707
end
1708
1709
--FWCposition 999999999999999999999999999999999999
1710
1711
function FWCposition()
1712
 turtle.select(coal)
1713
 turtle.refuel(1)
1714
 up()
1715
 up()
1716
 up()
1717
 up()
1718
 turtle.turnRight()
1719
 forward()
1720
 forward()
1721
 forward()
1722
 forward()
1723
 turtle.turnLeft()
1724
 forward()
1725
 forward()
1726
 print(" ")
1727
 print("Turtle in Base. Ready to set up farm.")
1728
 print("Be sure the turtle has all the materials it needs.")
1729
 print("Press Enter to get back into the menu.")
1730
 read()
1731
end
1732
1733
--FWCexpandchests
1734
1735
function FWCexpandchests()
1736
 print("Adding more chests!")
1737
 local amount = turtle.getItemCount(2)
1738
 turtle.turnLeft()
1739
 while not turtle.detectUp() do 
1740
  turtle.up()
1741
 end
1742
 turtle.select(3)
1743
 turtle.digUp()
1744
 turtle.select(2)
1745
 while amount > 0 do
1746
  up()
1747
  turtle.place()
1748
  amount = amount-1
1749
 end
1750
 turtle.select(3)
1751
 turtle.placeUp()
1752
 while turtle.down() do end
1753
 turtle.turnRight()
1754
 print("Finsihed!")
1755
 print("Press Enter to get back into the menu.")
1756
 read()
1757
end
1758
1759
--FWCtwobytwo
1760
1761
function FWCtwobytwo()
1762
 print("Chopping down 2x2 tree.")
1763
 while turtle.getFuelLevel() < 200 do
1764
  sleep(2)
1765
  turtle.select(1)
1766
  turtle.refuel(1)
1767
  print("Refueled!")
1768
 end
1769
 savestate = 2
1770
 cutWood()
1771
 print("Press Enter to get back into the menu.")
1772
 read()
1773
end
1774
1775
--FWConebyone
1776
1777
function FWConebyone()
1778
 print("Chopping down 1x1 tree.")
1779
 while turtle.getFuelLevel() < 200 do
1780
  sleep(2)
1781
  turtle.select(1)
1782
  turtle.refuel(1)
1783
  print("Refueled!")
1784
 end
1785
 turtle.select(2)
1786
 turtle.dig()
1787
 forward()
1788
 while turtle.compareUp() do
1789
  turtle.digUp()
1790
  up()
1791
 end
1792
 while not turtle.detectDown() do
1793
  turtle.down()
1794
 end
1795
 print("Finsihed!")
1796
 print("Press Enter to get back into the menu.")
1797
 read()
1798
end
1799
1800
--FWCdigSpace
1801
1802
function UWCdigBaseSpace()
1803
 turtle.turnLeft()
1804
 forward()
1805
 turtle.turnRight()
1806
 dd()
1807
 dd()
1808
 for i=1,3 do
1809
  for j=1,4 do
1810
   turtle.dig()
1811
   forward()
1812
   turtle.digUp()
1813
  end
1814
  if i<3 then
1815
   for j=1,4 do
1816
    back()
1817
   end
1818
   turtle.turnRight()
1819
   turtle.dig()
1820
   forward()
1821
   turtle.digUp()
1822
   turtle.turnLeft()
1823
  end
1824
 end
1825
 back()
1826
 turtle.digDown()
1827
 db()
1828
 turtle.digDown()
1829
 df()
1830
 up()
1831
 up()
1832
 turtle.turnLeft()
1833
end
1834
1835
function FWCdigSpace()
1836
 os.sleep(2)
1837
 turtle.select(1)
1838
 turtle.refuel(5)
1839
 back()
1840
 back()
1841
 UWCdigBaseSpace()
1842
 moveForward(5)
1843
 turtle.turnRight()
1844
 forward()
1845
 turtle.digDown()
1846
 down()
1847
 turtle.digDown()
1848
 down()
1849
 turtle.digDown()
1850
 for i=1,5 do
1851
  for j=1,11 do
1852
   turtle.dig()
1853
   turtle.forward()
1854
   turtle.digUp()
1855
   turtle.digDown()
1856
  end
1857
  turtle.turnRight()
1858
  turtle.dig()
1859
  turtle.forward()
1860
  turtle.turnRight()
1861
  turtle.digUp()
1862
  turtle.digDown()
1863
  for j=1,11 do
1864
   turtle.dig()
1865
   turtle.forward()
1866
   turtle.digUp()
1867
   turtle.digDown()   
1868
  end
1869
  if i < 5 then
1870
   turtle.turnLeft()
1871
   turtle.dig()
1872
   turtle.forward()
1873
   turtle.turnLeft()
1874
   turtle.digDown()
1875
   turtle.digUp()
1876
  end
1877
 end
1878
 turtle.back()
1879
 turtle.turnRight()
1880
 turtle.forward()
1881
 turtle.down()
1882
 turtle.digDown()
1883
 turtle.down()
1884
 for i=1,8 do
1885
  turtle.turnRight()
1886
  turtle.dig()
1887
  turtle.turnLeft()
1888
  turtle.dig()
1889
  turtle.forward()
1890
 end
1891
 turtle.turnLeft()
1892
 turtle.up()
1893
 turtle.up()
1894
 turtle.up()
1895
 turtle.up()
1896
 turtle.turnLeft()
1897
 moveForward(4)
1898
 turtle.turnRight()
1899
 moveForward(3)
1900
 turtle.turnLeft()
1901
 turtle.turnLeft()
1902
 print("Finished!")
1903
 print("Press Enter to get back into the menu!")
1904
 read()
1905
end
1906
1907
-- VARIABLE CHANGE MENU
1908
1909
function varBonemeal()
1910
 local input = 0
1911
1912
 print("Bonemeal")
1913
 print("Should the turtle take out bonemeal of the chest and use it on the tree to get wood faster?")
1914
 print("If not the turtle will wait until the tree is fully grown.")
1915
 print("Standard: true")
1916
 print("Use bonemeal: 1")
1917
 print("Dont use bonemeal: 0")
1918
 print("Current: " .. tostring(usebonemeal))
1919
 input = tonumber(read())
1920
 if input then
1921
  input = math.floor(input)
1922
  if input == 1 then usebonemeal = true
1923
  elseif input == 0 then usebonemeal = false end
1924
 end
1925
 clearScreen()
1926
1927
 print("Set to: " .. tostring(usebonemeal))
1928
 print("")
1929
 print("Bonemeal")
1930
 print("How many bonemeal should be used on the tree at the same time if the turtle should use it?")
1931
 print("Standard: 2")
1932
 print("Minimum: 1")
1933
 print("Maximum: 10")
1934
 print("Current: " .. amountbonemealtimes)
1935
 input = tonumber(read())
1936
 if input then
1937
  input = math.floor(input)
1938
  if input >= 1 and input <= 10 then amountbonemealtimes = input end
1939
 end
1940
 clearScreen()
1941
1942
 print("Set to: " .. amountbonemealtimes)
1943
 print("")
1944
 print("Saving variables...")
1945
 saveVariables()
1946
 sleep(0.2)
1947
 print("Saved variables!")
1948
 sleep(0.2)
1949
end
1950
1951
function varAmount()
1952
 local input = 0
1953
1954
 print("Amount")
1955
 print("Turtle needs this amount or more bonemeal in slot 2 before keep going.")
1956
 print("Standard: 8")
1957
 print("Minimum: 3 Maximum: 64")
1958
 print("Current: " .. amountMinBonemeal)
1959
 input = tonumber(read())
1960
 if input then
1961
  input = math.floor(input)
1962
  if input > 2 and input < 65 then amountMinBonemeal = input end
1963
 end
1964
 clearScreen()
1965
1966
 print("Set to: " .. amountMinBonemeal)
1967
 print("")
1968
 print("Amount")
1969
 print("Turtle needs this amount or more saplings in slot 1 before keep going.")
1970
 print("Standard: 17")
1971
 print("Minimum: 5 Maximum: 64")
1972
 print("Current: " .. amountMinSaplings)
1973
 input = tonumber(read())
1974
 if input then
1975
  input = math.floor(input)
1976
  if input > 4 and input < 65 then amountMinSaplings = input end
1977
 end
1978
 clearScreen()
1979
1980
 print("Set to: " .. amountMinSaplings)
1981
 print("")
1982
 print("Amount")
1983
 print("After chopping down trees, the turtle places some wood into the furnace.")
1984
 print("How many wood should be put into the furnace if bonemeal is used?")
1985
 print("Standard: 16")
1986
 print("Minimum: 0  Maximum: 64")
1987
 print("Current: " .. amountFurnaceWoodBonemeal)
1988
 input = tonumber(read())
1989
 if input then
1990
  input = math.floor(input)
1991
  if input >= 0 and input < 65 then amountFurnaceWoodBonemeal = input end
1992
 end
1993
 clearScreen()
1994
1995
 print("Set to: " .. amountFurnaceWoodBonemeal)
1996
 print("")
1997
 print("Amount")
1998
 print("After chopping down trees, the turtle places some wood into the furnace.")
1999
 print("How many wood should be put into the furnace if no bonemeal is used?")
2000
 print("Standard: 8")
2001
 print("Minimum: 0  Maximum: 64")
2002
 print("Current: " .. amountFurnaceWoodNoBonemeal)
2003
 input = tonumber(read())
2004
 if input then
2005
  input = math.floor(input)
2006
  if input >= 0 and input < 65 then amountFurnaceWoodNoBonemeal = input end
2007
 end
2008
 clearScreen()
2009
2010
 print("Set to: " .. amountFurnaceWoodNoBonemeal)
2011
 print("Amount")
2012
 print("At base the turtle refuels charcoal up to this fuel level before chopping down more trees.")
2013
 print("Standard: 1200")
2014
 print("Set this to 0 if you dont want the turtle to use coal!")
2015
 print("Current: " .. amountMinFuelLevel)
2016
 input = tonumber(read())
2017
 if input then
2018
  input = math.floor(input)
2019
  if input >= 0 then amountMinFuelLevel = input end
2020
 end
2021
 clearScreen()
2022
2023
 print("Set to: " .. amountMinFuelLevel)
2024
 print("")
2025
 print("Saving variables...")
2026
 saveVariables()
2027
 sleep(0.2)
2028
 print("Saved variables!")
2029
 sleep(0.2)
2030
end
2031
2032
function varTimer()
2033
 local input = 0
2034
2035
 print("Timer")
2036
 print("Turtle fails to take enough materials out of a chest.")
2037
 print("How long does he waits until it tries again?")
2038
 print("In this time the turtle can be terminated by the user.")
2039
 print("Standard: 2")
2040
 print("Minimum: 1")
2041
 print("Current: " .. cancelTimer)
2042
 input = tonumber(read())
2043
 if input then
2044
  input = math.floor(input)
2045
  if input >= 1 then cancelTimer = input end
2046
 end
2047
 clearScreen()
2048
2049
 print("Set to: " .. cancelTimer)
2050
 print("")
2051
 print("Timer")
2052
 print("Turtle fails to fertilize the tree with bonemeal.")
2053
 print("How long should it wait until it tries again?")
2054
 print("Standard: 120")
2055
 print("Current: " .. bonemealTimer)
2056
 input = tonumber(read())
2057
 if input then
2058
  input = math.floor(input)
2059
  if input >= 0 then bonemealTimer = input end
2060
 end
2061
 clearScreen()
2062
 
2063
 print("Set to: " .. bonemealTimer)
2064
 print("")
2065
 print("Timer")
2066
 print("Turtle planted the saplings.")
2067
 print("How long should the turtle wait before fertilizing the first time?")
2068
 print("Standard: 0")
2069
 print("Current: " .. bonemealFirstDelay)
2070
 input = tonumber(read())
2071
 if input then
2072
  input = math.floor(input)
2073
  if input >= 0 then bonemealFirstDelay = input end
2074
 end
2075
 clearScreen()
2076
2077
 print("Set to: " .. bonemealFirstDelay)
2078
 print("")
2079
 print("Saving variables...")
2080
 saveVariables()
2081
 sleep(0.2)
2082
 print("Saved variables!")
2083
 sleep(0.2)
2084
end
2085
2086
function varSlot()
2087
 local input = 0
2088
2089
 print("Slot")
2090
 print("Turtle goes back to base if the inventory slot has items in it.")
2091
 print("Which slot should it be if the turtle uses bonemeal?")
2092
 print("Standard: 14")
2093
 print("Minimum: 3  Maximum: 16")
2094
 print("Current: " .. amountMaxWoodSlotBonemeal)
2095
 turtle.select(tonumber(amountMaxWoodSlotBonemeal))
2096
 input = tonumber(read())
2097
 if input then
2098
  input = math.floor(input)
2099
  if input >= 3 and input <= 16 then amountMaxWoodSlotBonemeal = input end
2100
 end
2101
 clearScreen()
2102
2103
 print("Set to: " .. amountMaxWoodSlotBonemeal)
2104
 print("")
2105
 print("Slot")
2106
 print("Turtle goes back to base if inventory slot has items in it.")
2107
 print("Which slot should it be if the turtle doesnt use bonemeal?")
2108
 print("Standard: 7")
2109
 print("Minimum: 2  Maximum: 16")
2110
 print("Current: " .. amountMaxWoodSlotNoBonemeal)
2111
 turtle.select(tonumber(amountMaxWoodSlotNoBonemeal))
2112
 input = tonumber(read())
2113
 if input then
2114
  input = math.floor(input)
2115
  if input >= 2 and input <= 16 then amountMaxWoodSlotNoBonemeal = input end
2116
 end
2117
 clearScreen()
2118
2119
 print("Set to: " .. amountMaxWoodSlotNoBonemeal)
2120
 print("")
2121
 print("Saving variables...")
2122
 saveVariables()
2123
 sleep(0.2)
2124
 print("Saved variables!")
2125
 sleep(0.2)
2126
end
2127
2128
function varHeight()
2129
 local input = 0
2130
2131
 print("Height")
2132
 print("If the turtle debugs the farm, it checks how height it is.")
2133
 print("At which height should it turn back down?")
2134
 print("Standard: 55")
2135
 print("Minimum: 1  Maximum: 200")
2136
 print("Current: " .. debugMaxHeight)
2137
 input = tonumber(read())
2138
 if input then
2139
  input = math.floor(input)
2140
  if input > 0 and input < 201 then debugMaxHeight = input end
2141
 end
2142
 clearScreen()
2143
2144
 print("Set to: " ..debugMaxHeight)
2145
 print("")
2146
 print("Saving variables...")
2147
 saveVariables()
2148
 sleep(0.2)
2149
 print("Saved variables!")
2150
 sleep(0.2)
2151
end
2152
2153
function varPersistence()
2154
 print("Persistence")
2155
 print("If the turtle shutdown, because the chunk unload, while running a farm program the turtle restarts where it was left and keeps going. Because this might cause trouble in server, you can turn it on and off here by opening up this screen.")
2156
 print("")
2157
 persistence = not persistence
2158
 term.write("Persistence is ")
2159
 if persistence then
2160
  print("ENABLED!")
2161
 else
2162
  print("DISABLED!")
2163
 end
2164
 print("")
2165
 print("Saving variables...")
2166
 saveVariables()
2167
 sleep(0.2)
2168
 print("Saved variables!")
2169
 sleep(7)
2170
end
2171
2172
2173
function UWCvariables()
2174
 print("Welcome in the variable change menu.")
2175
 print("You have the choice to individualise your chopping turtle.")
2176
 print("These variables are just used for the farm and get saved and loaded every time.")
2177
 read()
2178
 print("Select a type of variables and you are getting shown the variables one by one.")
2179
 read()
2180
 print("If you want to skip a variable and leave it where it is, you just have to press Enter.")
2181
 read()
2182
 print("If you want to change a variable, type in the number and press Enter.")
2183
 print("Press Enter to continue...")
2184
 read()
2185
 clearScreen()
2186
end
2187
2188
2189
function UWCgodown()
2190
 while not turtle.detectDown() do
2191
  turtle.down()
2192
 end
2193
end
2194
2195
function control()
2196
 local blockslot = 1
2197
 local mode = "move"
2198
 local working = true
2199
 turtle.select(blockslot)
2200
2201
 function info()
2202
  clearScreen()
2203
  print("Navigate your turtle with your keyboard.")
2204
  print("W A S D --- Horizontal")
2205
  print("Space SHIFT --- Vertical")
2206
  print("E --- Switch between dig mode/ place mode/ move mode")
2207
  print("Q --- Select next slot")
2208
  print("Strg --- Leave the conrol interface.")
2209
  print("")
2210
  print("Turtle Mode: " .. mode)
2211
 end
2212
2213
 while working do
2214
  info()
2215
  local id, key = os.pullEvent("key")
2216
  if key == 29 then
2217
   working = false
2218
  elseif key == 16 then
2219
   blockslot = blockslot + 1
2220
   if blockslot == 17 then
2221
    blockslot = 1
2222
   end
2223
   turtle.select(blockslot)
2224
  elseif key == 30 then
2225
   turtle.turnLeft()
2226
  elseif key == 31 then
2227
   turtle.back()
2228
  elseif key == 32 then
2229
   turtle.turnRight()
2230
2231
  elseif mode == "move" then
2232
   if key == 17 then
2233
    turtle.forward()
2234
   elseif key == 57 then
2235
    turtle.up()
2236
   elseif key == 42 then
2237
    turtle.down()
2238
   elseif key == 18 then
2239
    mode = "dig"
2240
   end
2241
2242
  elseif mode == "dig" then
2243
   if key == 17 then
2244
    turtle.dig()
2245
   elseif key == 57 then
2246
    turtle.digUp()
2247
   elseif key == 42 then
2248
    turtle.digDown()
2249
   elseif key == 18 then
2250
    mode = "place"
2251
   end
2252
2253
  elseif mode == "place" then
2254
   if key == 17 then
2255
    turtle.place()
2256
   elseif key == 57 then
2257
    turtle.placeUp()
2258
   elseif key == 42 then
2259
    turtle.placeDown()
2260
   elseif key == 18 then
2261
    mode = "move"
2262
   end
2263
  end
2264
 end
2265
end
2266
2267
2268
--MAIN PROGRAM
2269
2270
if fs.exists(savefile) then
2271
 loadVariables()
2272
end
2273
2274
checkForLastSession()
2275
2276
while running == true do
2277
 runMenu()
2278
end