forked from Courseplay/courseplay
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspecialTools.lua
More file actions
1956 lines (1728 loc) · 81.2 KB
/
specialTools.lua
File metadata and controls
1956 lines (1728 loc) · 81.2 KB
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
function courseplay:setNameVariable(workTool)
--print(" base: CPloading: "..tostring(workTool.name))
if workTool.cp == nil then
workTool.cp = {};
end;
-- local specList = { 'AICombine', 'AITractor', 'AnimatedVehicle', 'BaleLoader', 'Baler', 'BunkerSiloCompacter', 'Combine', 'Cultivator', 'Cylindered', 'Foldable', 'FruitPreparer', 'MixerWagon', 'Mower', 'Plough', 'Shovel', 'SowingMachine', 'Sprayer', 'Steerable', 'Tedder', 'Trailer', 'Windrower' };
-- Only default specs!
for i,spec in pairs(workTool.specializations) do
if spec == AICombine then workTool.cp.hasSpecializationAICombine = true;
elseif spec == AITractor then workTool.cp.hasSpecializationAITractor = true;
elseif spec == AnimatedVehicle then workTool.cp.hasSpecializationAnimatedVehicle = true;
elseif spec == BaleLoader then workTool.cp.hasSpecializationBaleLoader = true;
elseif spec == Baler then workTool.cp.hasSpecializationBaler = true;
elseif spec == BunkerSiloCompacter then workTool.cp.hasSpecializationBunkerSiloCompacter = true;
elseif spec == Combine then workTool.cp.hasSpecializationCombine = true;
elseif spec == Cultivator then workTool.cp.hasSpecializationCultivator = true;
elseif spec == Cylindered then workTool.cp.hasSpecializationCylindered = true;
elseif spec == Foldable then workTool.cp.hasSpecializationFoldable = true;
elseif spec == FruitPreparer then workTool.cp.hasSpecializationFruitPreparer = true;
elseif spec == MixerWagon then workTool.cp.hasSpecializationMixerWagon = true;
elseif spec == Mower then workTool.cp.hasSpecializationMower = true;
elseif spec == Plough then workTool.cp.hasSpecializationPlough = true;
elseif spec == Shovel then workTool.cp.hasSpecializationShovel = true;
elseif spec == SowingMachine then workTool.cp.hasSpecializationSowingMachine = true;
elseif spec == Sprayer then workTool.cp.hasSpecializationSprayer = true;
elseif spec == Steerable then workTool.cp.hasSpecializationSteerable = true;
elseif spec == Tedder then workTool.cp.hasSpecializationTedder = true;
elseif spec == Trailer then workTool.cp.hasSpecializationTrailer = true;
elseif spec == Windrower then workTool.cp.hasSpecializationWindrower = true;
end;
--[[
-- alternate possible query:
for i,specClassName in pairs(specList) do
if spec == _G[specClassName] then
workTool.cp['hasSpecialization' .. specClassName] = true;
end;
end;
]]
end;
--[[ DEBUG
print(nameNum(workTool) .. ': default specs list');
for i,specClassName in pairs(specList) do
local var = 'hasSpecialization' .. specClassName;
if workTool.cp[var] then
print(('\t[%s] %s=true'):format(specClassName, var));
end;
end;
--]]
--------------------------------------------------------------
--John Deere S650 [Big Boss Modding]
if Utils.endsWith(workTool.configFileName, 'JohnDeereS650NW.xml') then
workTool.cp.isJohnDeereS650 = true;
-- Claas Quantum 3800K [Vertex Design]
elseif workTool.psGrassactive ~= nil and workTool.psStrawactive ~= nil then --and Utils.endsWith(workTool.configFileName, 'claas_quantum_3800k.xml') then
workTool.cp.isClaasQuantum3800K = true;
-- Poettinger Eurocat 315H [MoreRealistic]
elseif workTool.typeName == 'moreRealistic.mower_animated' and Utils.endsWith(workTool.configFileName, 'poettingerEurocat315H.xml') then
workTool.cp.isMRpoettingerEurocat315H = true;
--Case IH Magnum 340 [Giants Titanium]
elseif Utils.endsWith(workTool.configFileName, "caseIHMagnum340.xml") or Utils.endsWith(workTool.configFileName, "caseIHMagnum340TwinWheel.xml") then
workTool.cp.isCaseIHMagnum340Titanium = true;
--Case IH Magnum 340 [Giants Titanium]
elseif Utils.endsWith(workTool.configFileName, "caseIHPuma160.xml") then
workTool.cp.isCaseIHPuma160Titanium = true;
--John Deere 864 Premium [BJR]
elseif Utils.endsWith(workTool.configFileName, "JohnDeere864Premium.xml") then
workTool.cp.isJohnDeere864Premium = true;
--AugerWagons
elseif workTool.cp.hasSpecializationAugerWagon then
workTool.cp.isAugerWagon = true;
if Utils.endsWith(workTool.configFileName, "horschTitan34UW.xml") then
workTool.cp.isHorschTitan34UWTitaniumAddon = true;
workTool.cp.foldPipeAtWaitPoint = true;
end;
elseif workTool.cp.hasSpecializationOverloader then
workTool.cp.isAugerWagon = true;
workTool.cp.hasSpecializationOverloaderV2 = workTool.overloaderVersion ~= nil and workTool.overloaderVersion >= 2;
elseif workTool.cp.hasSpecializationAgrolinerTUW20 then
workTool.cp.isAugerWagon = true;
if Utils.endsWith(workTool.configFileName, "AgrolinerTUW20.xml") then
workTool.cp.isAgrolinerTUW20 = true;
workTool.cp.foldPipeAtWaitPoint = true;
end;
elseif workTool.cp.hasSpecializationOvercharge then
workTool.cp.isAugerWagon = true;
if Utils.endsWith(workTool.configFileName, "AgrolinerTUW20.xml") then
workTool.cp.isAgrolinerTUW20 = true;
workTool.cp.foldPipeAtWaitPoint = true;
elseif Utils.endsWith(workTool.configFileName, "HaweULW2600T.xml") then
workTool.cp.isHaweULW2600T = true;
workTool.cp.foldPipeAtWaitPoint = true;
elseif Utils.endsWith(workTool.configFileName, "HaweULW3000T.xml") then
workTool.cp.isHaweULW3000T = true;
workTool.cp.foldPipeAtWaitPoint = true;
end;
elseif workTool.cp.hasSpecializationHaweSUW then
workTool.cp.isAugerWagon = true;
if Utils.endsWith(workTool.configFileName, "Hawe_SUW_4000.xml") then
workTool.cp.isHaweSUW4000 = true;
elseif Utils.endsWith(workTool.configFileName, "Hawe_SUW_5000.xml") then
workTool.cp.isHaweSUW5000 = true;
end;
elseif workTool.cp.hasSpecializationBigBear then
workTool.cp.isAugerWagon = true;
workTool.cp.isRopaBigBear = true;
workTool.cp.foldPipeAtWaitPoint = true;
workTool.cp.hasSpecializationBigBearV2 = workTool.setUnloading ~= nil and workTool.setWorkMode~= nil and workTool.setActiveWorkMode ~= nil;
--[[
elseif workTool.turnOn ~= nil and workTool.inRangeDraw ~= nil and workTool.Go ~= nil and workTool.Go.trsp ~= nil and workTool.CheckDone ~= nil and workTool.CheckDone.trsp then
workTool.cp.isAugerWagon = true;
workTool.cp.isBrentAvalanche = true;
]]
elseif workTool.animationParts ~= nil and workTool.animationParts[2] ~= nil and workTool.toggleUnloadingState ~= nil and workTool.setUnloadingState ~= nil then
workTool.cp.isAugerWagon = true;
workTool.cp.isTaarupShuttle = true;
--Weidemann4270CX100T
elseif Utils.endsWith(workTool.configFileName, "weidemann4270CX100T.xml") then
workTool.cp.isWeidemann4270CX100T = true
--HoseRef liquid manure trailers [Eifok Team] (CP implementation v2)
elseif workTool.cp.hasSpecializationHoseRef then
workTool.cp.hasHoseRef = true;
workTool.cp.isHoseRefTransporter = workTool.hasPump;
workTool.cp.isHoseRefSprayer = workTool.hasPump and workTool.cp.hasSpecializationSprayer and workTool.allowsSpraying;
workTool.cp.hasEifokZunhammerAttachable = false;
--Eifok liquid manure attachable pack [Eifok Team]
elseif workTool.moescha ~= nil and Utils.endsWith(workTool.configFileName, "moescha.xml") then
workTool.cp.isEifokZunhammerMoescha = true;
workTool.cp.isEifokZunhammerAttachable = true;
elseif Utils.endsWith(workTool.configFileName, "vogelsang.xml") then
workTool.cp.isEifokZunhammerVogelsang = true;
workTool.cp.isEifokZunhammerAttachable = true;
elseif workTool.vibro ~= nil and Utils.endsWith(workTool.configFileName, "zunhammerVibro.xml") then
workTool.cp.isEifokZunhammerVibro = true;
workTool.cp.isEifokZunhammerAttachable = true;
--Mchale998 bale wrapper [Bergwout]
elseif Utils.endsWith(workTool.configFileName, "Mchale998.xml") then
workTool.cp.isMchale998 = true
--Rolmasz S061 "Pomorzanin" [Maciusboss1 & Burner]
elseif Utils.endsWith(workTool.configFileName, "S061.xml") and workTool.setTramlinesOn ~= nil and workTool.leftMarkerRope ~= nil and workTool.leftMarkerSpeedRotatingParts ~= nil then
workTool.cp.isRolmaszS061 = true;
--Universal Bale Trailer (UBT)
elseif workTool.numAttacherParts ~= nil and workTool.autoLoad ~= nil and workTool.loadingIsActive ~= nil and workTool.unloadLeft ~= nil and workTool.unloadRight ~= nil and workTool.unloadBack ~= nil and workTool.typeOnTrailer ~= nil and workTool.fillLevelMax ~= nil then
workTool.cp.isUBT = true;
--Guellepack v2 [Bayerbua]
elseif workTool.fillerArmInRange ~= nil then
workTool.cp.isFeldbinder = true
elseif Utils.endsWith(workTool.configFileName, "KotteGARANTProfiVQ32000.xml") and workTool.fillerArmNode ~= nil then
workTool.cp.isKotteGARANTProfiVQ32000 = true
--Urf-Specialisation
elseif workTool.sprayFillLevel ~= nil and workTool.sprayCapacity ~= nil then
workTool.cp.hasUrfSpec = true
--Silage shields
elseif Utils.endsWith(workTool.configFileName, "holaras.xml") then
workTool.cp.isSilageShield = true
elseif Utils.endsWith(workTool.configFileName, "Stegemann.xml") then
workTool.cp.isSilageShield = true
--Abbey Sprayer Pack [FS-UK Modteam]
elseif Utils.endsWith(workTool.configFileName, "Abbey_AP900.xml") then
workTool.cp.isAbbeySprayerPack = true;
workTool.cp.isAbbeyAP900 = true;
elseif Utils.endsWith(workTool.configFileName, "Abbey_3000R.xml") then
workTool.cp.isAbbeySprayerPack = true;
workTool.cp.isAbbey3000R = true;
elseif Utils.endsWith(workTool.configFileName, "Abbey_2000R.xml") then
workTool.cp.isAbbeySprayerPack = true;
workTool.cp.isAbbey2000R = true;
elseif Utils.endsWith(workTool.configFileName, "Abbey_3000_Nurse.xml") then
workTool.cp.isAbbeySprayerPack = true;
workTool.cp.isAbbey3000Nurse = true;
--JF-Stoll 1060 [NI Modding]
elseif Utils.endsWith(workTool.configFileName, "JF_1060.xml") then
workTool.cp.isJF1060 = true;
--Kverneland Mower Pack [NI Modding]
elseif Utils.endsWith(workTool.configFileName, "Kverneland_4028.xml") then
workTool.cp.isKvernelandMowerPack = true;
workTool.cp.isKverneland4028 = true;
elseif Utils.endsWith(workTool.configFileName, "Kverneland_4028_AS.xml") then
workTool.cp.isKvernelandMowerPack = true;
workTool.cp.isKverneland4028AS = true;
elseif Utils.endsWith(workTool.configFileName, "Kverneland_KD240.xml") then
workTool.cp.isKvernelandMowerPack = true;
workTool.cp.isKvernelandKD240 = true;
elseif Utils.endsWith(workTool.configFileName, "Kverneland_KD240F.xml") then
workTool.cp.isKvernelandMowerPack = true;
workTool.cp.isKvernelandKD240F = true;
elseif Utils.endsWith(workTool.configFileName, "Taarup_3532F.xml") then
workTool.cp.isKvernelandMowerPack = true;
workTool.cp.isKverneland3532F = true;
--Taarup Mower Pack [NI Modding]
elseif Utils.endsWith(workTool.configFileName, "Taarup_5090.xml") then
workTool.cp.isTaarupMowerPack = true;
workTool.cp.isTaarup5090 = true;
--Poettinger Alpha/X8 Mower Pack [Eifok Team]
elseif Utils.endsWith(workTool.configFileName, "PoettingerAlpha.xml") then
workTool.cp.isPoettingerAlphaX8MowerPack = true;
workTool.cp.isPoettingerAlpha = true;
elseif Utils.endsWith(workTool.configFileName, "PoettingerX8.xml") then
workTool.cp.isPoettingerAlphaX8MowerPack = true;
workTool.cp.isPoettingerX8 = true;
--Claas Quadrant 1200 [Eifok Team]
elseif Utils.endsWith(workTool.configFileName, "Claas_Quadrant_1200.xml") then
workTool.cp.isClaasQuadrant1200 = true;
--Krone Swadro 900 [NI-Modding]
elseif workTool.rowerFoldingParts and Utils.endsWith(workTool.configFileName, "KroneSwadro900.xml") then
workTool.cp.isKroneSwadro900 = true;
--Claas Liner 4000 [LS-Landtechnik & Fuqsbow-Team]
elseif Utils.endsWith(workTool.configFileName, "liner4000.xml") then
workTool.cp.isClaasLiner4000 = true;
--Ursus Z586 bale wrapper [Giants]
elseif Utils.endsWith(workTool.configFileName, "ursusZ586.xml") then
workTool.cp.isUrsusZ586 = true;
--Tebbe HS180 [Stefan Maurus]
elseif Utils.endsWith(workTool.configFileName, "TebbeHS180.xml") then
workTool.cp.isTebbeHS180 = true;
--Fuchs liquid manure trailer [Stefan Maurus]
elseif Utils.endsWith(workTool.configFileName, "FuchsGuellefass.xml") and workTool.isFuchsFass then
workTool.cp.isFuchsLiquidManure = true;
--Claas Conspeed [SFM]
elseif Utils.endsWith(workTool.configFileName, "claasConspeed.xml") then
workTool.cp.isClaasConspeedSFM = true;
--Poettinger Mex 6 [Giants]
elseif Utils.endsWith(workTool.configFileName, "poettingerMex6.xml") then
workTool.cp.isPoettingerMex6 = true;
--Sugarbeet Loaders [burner]
elseif Utils.endsWith(workTool.configFileName, "RopaEuroMaus.xml") then
workTool.cp.isRopaEuroMaus = true;
elseif Utils.endsWith(workTool.configFileName, "HolmerTerraFelis.xml") then
workTool.cp.isHolmerTerraFelis = true;
elseif Utils.endsWith(workTool.configFileName, "RopaNawaRoMaus.xml") then
workTool.cp.isRopaNawaRoMaus = true;
--Harvesters (steerable)
elseif Utils.endsWith(workTool.configFileName, "RopaEuroTiger_V8_3_XL.xml") then
workTool.cp.isRopaEuroTiger = true;
--Harvesters (steerable) [Giants]
elseif Utils.endsWith(workTool.configFileName, "grimmeMaxtron620.xml") then
workTool.cp.isHarvesterSteerable = true;
workTool.cp.isGrimmeMaxtron620 = true;
elseif Utils.endsWith(workTool.configFileName, "grimmeTectron415.xml") then
workTool.cp.isHarvesterSteerable = true;
workTool.cp.isGrimmeTectron415 = true;
--Harvesters (attachable) [Giants]
elseif Utils.endsWith(workTool.configFileName, "grimmeRootster604.xml") then
workTool.cp.isHarvesterAttachable = true;
workTool.cp.isGrimmeRootster604 = true;
elseif Utils.endsWith(workTool.configFileName, "grimmeSE75-55.xml") then
workTool.cp.isHarvesterAttachable = true;
workTool.cp.isGrimmeSE7555 = true;
--Combines [Giants]
elseif Utils.endsWith(workTool.configFileName, "fahrM66.xml") or Utils.endsWith(workTool.configFileName, "fahrM66EX.xml") then
workTool.cp.isFahrM66 = true;
elseif Utils.endsWith(workTool.configFileName, "caseIH7130.xml") then
workTool.cp.isCaseIH7130 = true;
elseif Utils.endsWith(workTool.configFileName, "caseIH9230.xml") then
workTool.cp.isCaseIH9230 = true;
elseif Utils.endsWith(workTool.configFileName, "caseIH9230Crawler.xml") then
workTool.cp.isCaseIH9230Crawler = true;
elseif Utils.endsWith(workTool.configFileName, "deutz5465H.xml") then
workTool.cp.isDeutz5465H = true;
--Cutters [Giants]
elseif Utils.endsWith(workTool.configFileName, "caseIH3162Cutter.xml") then
workTool.cp.isCaseIH3162Cutter = true;
--Others
elseif Utils.endsWith(workTool.configFileName, "KirovetsK700A.xml") then
workTool.cp.isKirovetsK700A = true;
end;
end;
------------------------------------------------------------------------------------------
function courseplay:isSpecialSowingMachine(workTool)
return workTool.cp.hasSpecializationSowingMachineWithTank;
end;
function courseplay:isSpecialSprayer(workTool)
return workTool.cp.isAbbeySprayerPack;
end;
function courseplay:isSpecialChopper(workTool)
if workTool.cp.isJF1060 or workTool.cp.isPoettingerMex6 then
if workTool.grainTankFillLevel == nil then
workTool.grainTankFillLevel = 0;
end;
if workTool.grainTankCapacity == nil then
workTool.grainTankCapacity = 0;
end;
if workTool.cp.isChopper == nil then
workTool.cp.isChopper = true
end
return true;
end
return false
end
function courseplay:isSpecialMower(workTool)
return workTool.cp.isPoettingerAlphaX8MowerPack or workTool.cp.isKvernelandMowerPack or workTool.cp.isTaarupMowerPack;
end
function courseplay:isSpecialBaler(workTool)
return workTool.cp.isClaasQuadrant1200 or workTool.cp.isJohnDeere864Premium;
end;
function courseplay:isSpecialRoundBaler(workTool)
return workTool.cp.isJohnDeere864Premium;
end;
function courseplay:isSpecialBaleLoader(workTool)
return workTool.cp.isUBT;
end;
function courseplay:isSpecialCombine(workTool, specialType, fileNames)
if specialType ~= nil then
if specialType == "sugarBeetLoader" then
if (workTool.cp.isRopaEuroMaus or workTool.cp.isHolmerTerraFelis or workTool.cp.isRopaNawaRoMaus) and workTool.unloadingTrigger ~= nil and workTool.unloadingTrigger.node ~= nil then
if workTool.grainTankFillLevel == nil then
workTool.grainTankFillLevel = 0;
end;
if workTool.grainTankCapacity == nil then
workTool.grainTankCapacity = 0;
end;
return true;
end;
end;
end;
--[[if fileNames ~= nil and table.getn(fileNames) > 0 then
for i=1, table.getn(fileNames) do
if Utils.endsWith(workTool.configFileName, fileNames[i] .. ".xml") then
return true;
end;
end;
return false;
end;]]
return workTool.cp.isJF1060;
end
function courseplay:handleSpecialTools(self,workTool,unfold,lower,turnOn,allowedToDrive,cover,unload,ridgeMarker)
local implementsDown = lower and turnOn
if workTool.PTOId then
workTool:setPTO(false)
end
--Claas Quantum 3800K [Vertex Design]
if workTool.cp.isClaasQuantum3800K then
--correctly turn off the grass particle system, as it's not being done in the trailer's "Pickup" spec
if turnOn ~= nil then
if turnOn then
if workTool.cp.hasDeactivatedGrassPS then
workTool.cp.hasDeactivatedGrassPS = false;
end;
elseif not turnOn and not workTool.psGrassactive and not workTool.cp.hasDeactivatedGrassPS then
for _, ps in pairs(workTool.grassParticleSystems) do
Utils.setEmittingState(ps.particleSystem, false);
end;
workTool.cp.hasDeactivatedGrassPS = true;
end;
end;
return false, allowedToDrive;
--Zunhammer Liquid Manure Pack [Eifok Team]
elseif workTool.cp.hasEifokZunhammerAttachable and self.cp.mode == 4 then
local attachable = workTool.cp.eifokZunhammerAttachable;
if attachable.cp.isEifokZunhammerMoescha then
--no special handling needed
elseif attachable.cp.isEifokZunhammerVogelsang then
if not attachable.isTrans then --set to transport position
allowedToDrive = false;
if attachable.isPark then
attachable:setParking(false);
end;
end;
if unfold ~= nil and unfold ~= attachable.setUnfold then
attachable:setFoldingDir(unfold);
end;
if allowedToDrive then
allowedToDrive = attachable.isFold or attachable.isUnfold; --basic isFolding for Vogelsang
end;
elseif attachable.cp.isEifokZunhammerVibro then
if unfold ~= nil and unfold ~= attachable.setUnfold then
attachable:setFoldingDir(unfold);
end;
if implementsDown ~= nil and attachable:isLowered() ~= implementsDown and attachable.attacherVehicleJointIndex ~= nil then
workTool:setJointMoveDown(attachable.attacherVehicleJointIndex, implementsDown, false);
end;
if allowedToDrive then
allowedToDrive = attachable.isFold or attachable.isUnfold; --basic isFolding for Vibro
end;
end;
return false, allowedToDrive;
elseif workTool.cp.isHoseRefTransporter then
-- print(string.format('handleSpecialTools(): isHoseRefTransporter, unload=%s -> %s handleSpecialSprayer(..., "push")', tostring(unload), unload and 'call' or 'don\'t call'));
if unload then
local fillLevel = workTool.fillLevel * 100 / workTool.capacity;
if self.cp.tipperFillLevel ~= nil and self.cp.tipperCapacity ~= nil then
fillLevel = self.cp.tipperFillLevel * 100 / self.cp.tipperCapacity;
end;
return courseplay:handleSpecialSprayer(self, workTool, fillLevel, nil, allowedToDrive, nil, nil, nil, "push");
end;
--Mchale998 bale wrapper
elseif workTool.cp.isMchale998 then
if workTool.baleWrapperState == 3 then
allowedToDrive = false
elseif workTool.baleWrapperState == 4 then
workTool:doStateChange(8)
end
return false, allowedToDrive;
--Rolmasz S061 "Pomorzanin"
elseif workTool.cp.isRolmaszS061 then
-- 1 = lower/raise, 2/3 = left/right arm, 4 = cover, 5/6 = left/right ridgeMarker (fold and extend), 7/8 = left/right ridgeMarker (up and down)
local animParts = workTool.animationParts;
local isLoweringRaising = courseplay:isAnimationPartPlaying(workTool, 1);
local isRaised = animParts[1].clipEndTime == false;
local isLowered = animParts[1].clipEndTime;
local isFolded = animParts[2].clipStartTime and animParts[3].clipStartTime;
local isUnfolded = animParts[2].clipEndTime and animParts[3].clipEndTime;
--local isFolding = courseplay:isAnimationPartPlaying(workTool, { 2, 3, 5, 6, 7, 8 });
local isFolding = courseplay:isAnimationPartPlaying(workTool, { 2, 3 });
local isMovingRidgeMarkers = courseplay:isAnimationPartPlaying(workTool, { 5, 6, 7, 8 });
local leftRidgeMarkerExtended = animParts[5].clipEndTime;
local rightRidgeMarkerExtended = animParts[6].clipEndTime;
if unfold then
if isRaised and isFolded and not isMovingRidgeMarkers and not (leftRidgeMarkerExtended or rightRidgeMarkerExtended) then
workTool:setAnimationTime(2, animParts[2].animDuration); --unfold left arm
workTool:setAnimationTime(3, animParts[3].animDuration); --unfold right arm
end;
else
if isRaised and isUnfolded and not isMovingRidgeMarkers then
if not (leftRidgeMarkerExtended or rightRidgeMarkerExtended) then
workTool:setAnimationTime(2, animParts[2].startPosition); --fold left arm
workTool:setAnimationTime(3, animParts[3].startPosition); --fold right arm
end;
--stow ridgeMarkers
for i=5,8 do
if animParts[i].clipEndTime then
workTool:setAnimationTime(i, animParts[i].startPosition);
end;
end;
end;
end;
if self.cp.ridgeMarkersAutomatic and ridgeMarker and isUnfolded then
if not leftRidgeMarkerExtended then
workTool:setAnimationTime(5, animParts[5].animDuration);
end;
if not rightRidgeMarkerExtended then
workTool:setAnimationTime(6, animParts[6].animDuration);
end;
--Note: for some reason, startPosition = down and animDuration = up
if ridgeMarker == 0 then --none
--raise ridgeMarkers
if animParts[7].clipStartTime then
workTool:setAnimationTime(7, animParts[7].animDuration);
--print("raise left ridgeMarker (both)");
end;
if animParts[8].clipStartTime then
workTool:setAnimationTime(8, animParts[8].animDuration);
--print("raise right ridgeMarker (both)");
end;
elseif ridgeMarker == 1 then --left
if animParts[8].clipStartTime then
workTool:setAnimationTime(8, animParts[8].animDuration);
--print("raise right ridgeMarker");
end;
if animParts[7].clipEndTime then
workTool:setAnimationTime(7, animParts[7].startPosition);
--print("lower left ridgeMarker");
end;
elseif ridgeMarker == 2 then --right
if animParts[7].clipStartTime then
workTool:setAnimationTime(7, animParts[7].animDuration);
--print("raise left ridgeMarker");
end;
if animParts[8].clipEndTime then
workTool:setAnimationTime(8, animParts[8].startPosition);
--print("lower right ridgeMarker");
end;
end;
end;
if isFolding or isLoweringRaising then
allowedToDrive = false;
end;
if lower then
if isUnfolded and not isLowered and not isLoweringRaising then
workTool:aiLower();
end;
else
workTool:aiRaise();
end;
if turnOn then
if isLowered and not workTool.isTurnedOn then
workTool:aiTurnOn();
end;
else
workTool:aiTurnOff();
end;
return false, allowedToDrive;
--Universal Bale Trailer
elseif workTool.cp.isUBT then
if not workTool.fillLevelMax == workTool.numAttachers[workTool.typeOnTrailer] then
workTool.fillLevelMax = workTool.numAttachers[workTool.typeOnTrailer];
end;
if workTool.capacity == nil or (workTool.capacity ~= nil and workTool.capacity ~= workTool.fillLevelMax) then
workTool.capacity = workTool.fillLevelMax;
end;
if not workTool.autoLoad then
workTool.autoLoad = true;
end;
if workTool.loadingIsActive ~= turnOn then
workTool.loadingIsActive = turnOn;
end;
if unload then
local root = getRootNode();
for i=1, workTool.numAttachers[workTool.typeOnTrailer] do
local attacher = workTool.attacher[workTool.typeOnTrailer][i];
if attacher.attachedObject ~= nil then
--ORIG: if workTool.ulRef[workTool.ulMode][1] == g_i18n:getText("UNLOAD_TRAILER") then
if workTool.ulRef[workTool.ulMode][3] == 0 then --verrrrry dirty: unload on trailer
local x,y,z = getWorldTranslation(attacher.attachedObject);
local rx,ry,rz = getWorldRotation(attacher.attachedObject);
setRigidBodyType(attacher.attachedObject,"Dynamic");
setTranslation(attacher.attachedObject,x,y,z);
setRotation(attacher.attachedObject,rx,ry,rz);
link(root,attacher.attachedObject);
attacher.attachedObject = nil;
workTool.fillLevel = workTool.fillLevel - 1;
else
local x,y,z = getWorldTranslation(attacher.attachedObject);
local rx,ry,rz = getWorldRotation(attacher.attachedObject);
local nx,ny,nz = getWorldTranslation(workTool.attacherLevel[workTool.typeOnTrailer]);
local tx,ty,tz = getWorldTranslation(workTool.ulRef[workTool.ulMode][3]);
local x = x + (tx - nx);
local y = y + (ty - ny);
local z = z + (tz - nz);
local tH = getTerrainHeightAtWorldPos(g_currentMission.terrainRootNode, x, 0, z);
local relHeight = ny - tH;
setRigidBodyType(attacher.attachedObject,"Dynamic");
setTranslation(attacher.attachedObject,x,(y - relHeight),z);
setRotation(attacher.attachedObject,rx,ry,rz);
link(root,attacher.attachedObject);
attacher.attachedObject = nil;
workTool.fillLevel = workTool.fillLevel - 1;
end;
end;
end;
end;
return true, allowedToDrive;
--RopaEuroTiger
elseif self.cp.isRopaEuroTiger then
local fold = self:getToggledFoldDirection()
if unfold then
if fold == -1 then
self:setFoldState(fold, false);
end
else
if fold == 1 and self.grainTankFillLevel == 0 then
self:setFoldState(fold, false);
end
end
if self.foldAnimTime > 0 and self.foldAnimTime < 1 then
return true, false
end;
if self.steeringMode ~= 5 and lower then
self:setSteeringMode(5)
end
if not lower then
self:setSteeringMode(4)
end
return false, allowedToDrive
end;
--KotteGARANTProfiVQ32000
if workTool.cp.isKotteGARANTProfiVQ32000 then
if workTool.cp.crabSteerMode ~= 0 then
local ridgeMarker = self.Waypoints[self.recordnumber].ridgeMarker
if not implementsDown then
workTool.crabSteerMode = 0
else
workTool.crabSteerMode = workTool.cp.crabSteerMode
if ridgeMarker == 1 then
workTool.HGdirection = 1;
courseplay:changeToolOffsetX(self, nil, 3, true);
elseif ridgeMarker == 2 then
workTool.HGdirection = -1;
courseplay:changeToolOffsetX(self, nil, -3, true);
end
end
end
return false, allowedToDrive
--Urf-specialisation
elseif workTool.cp.hasUrfSpec then
if workTool.sprayFillLevel == 0 and workTool.isFertilizing > 1 then
self.cp.urfStop = true
end
return false, allowedToDrive
--KvernelandMowerPack
elseif workTool.cp.isKvernelandMowerPack then
if workTool.cp.isKvernelandKD240 then
if workTool.TransRot ~= nil and workTool.TransRot ~= down then
workTool:setTransRot(not unfold);
end
if workTool.setArmOne ~= nil then
workTool:setArmOne(implementsDown);
end
elseif workTool.cp.isKverneland4028AS or workTool.cp.isKverneland4028 then
if workTool.TransRot ~= nil and workTool.TransRot ~= down then
workTool:setTransRot(unfold);
end
if workTool.setSideSkirts ~= nil and workTool.isSideSkirtsOn ~= unfold then
workTool:setSideSkirts(unfold);
end
if workTool.setWheelRot ~= nil and (workTool.isWheelRotOn == implementsDown) or (workTool.isWheelRotOn == nil and not implementsDown) then
workTool:setWheelRot(not implementsDown );
end
else
if workTool.TransRot ~= nil and workTool.TransRot ~= down then
workTool:setTransRot(implementsDown);
end
if workTool.setSideSkirts ~= nil and workTool.isSideSkirtsOn ~= unfold then
workTool:setSideSkirts(unfold);
end
end
if workTool.isTurnedOn ~= turnOn then
workTool:setIsTurnedOn(turnOn);
end
return true, allowedToDrive
-- TaarupMowerPack
elseif workTool.cp.isTaarupMowerPack then
if workTool.isReadyToTransport then
workTool:setTransport(not unfold)
end
if down ~= workTool.mowerFoldingParts[1].mainPart.isDown then
for k, part in pairs(workTool.mowerFoldingParts) do
workTool:setIsArmDown(k, implementsDown);
end;
end
if workTool.isTurnedOn ~= turnOn then
workTool:setIsTurnedOn(turnOn);
end
--custom isFolding for Kverneland mowers
if workTool.mowerFoldingParts ~= nil then
for partIdx, foldingPart in pairs(workTool.mowerFoldingParts) do
local mainPart = foldingPart.mainPart;
local axes, curRot = { "x", "y", "z" }, {};
curRot.x, curRot.y, curRot.z = getRotation(mainPart.joint.jointNode);
--print(string.format("part %d: minRot=%f,%f,%f, maxRot=%f,%f,%f, curRot=%f,%f,%f", partIdx, mainPart.minRot[1], mainPart.minRot[2], mainPart.minRot[3], mainPart.maxRot[1], mainPart.maxRot[2], mainPart.maxRot[3], curRot.x, curRot.y, curRot.z));
for i,axis in pairs(axes) do
if courseplay:isBetween(curRot[axis], mainPart.minRot[i], mainPart.maxRot[i], false) then
--print(string.format("isFolding: curRot.%s is between mainPart.minRot[%d] and mainPart.maxRot[%d]", axis, i, i));
allowedToDrive = false;
end;
end;
end;
end
return true, allowedToDrive
--Claas Quadrant 1200 / John Deere 864 Premium
elseif workTool.cp.isClaasQuadrant1200 or workTool.cp.isJohnDeere864Premium then
if unfold ~= nil and turnOn ~= nil and lower ~= nil then
if workTool.cp.isClaasQuadrant1200 then
if not unfold then
workTool:emptyBaler(true);
workTool:setPTO(true)
end
if workTool.sl.isOpen ~= unfold then
workTool:openSlide(unfold);
end
if workTool.pu.bDown ~= implementsDown then
workTool:releasePickUp(implementsDown)
end
if workTool.isTurnedOn ~= unfold then
workTool.isTurnedOn = unfold
end
elseif workTool.cp.isJohnDeere864Premium then
--EMPTY BALER
if not unfold then
if #(workTool.bales) == 0 and workTool.fillLevel > 200 and workTool.coverEdge.isLoaded and workTool.shouldNet == false and not workTool.isNetting then
workTool:setShouldNet(true);
elseif #(workTool.bales) > 0 then
if workTool.balerUnloadingState == Baler.UNLOADING_CLOSED then --unload bale
workTool:setIsUnloadingBale(true);
end;
elseif workTool.fillLevel == 0 and workTool.balerUnloadingState == Baler.UNLOADING_OPEN then
workTool:setIsUnloadingBale(false);
if workTool.isTurnedOn then
workTool:setIsTurnedOn(false, false);
end;
elseif workTool.fillLevel <= 200 and workTool.balerUnloadingState == Baler.UNLOADING_CLOSED and not workTool.isNetting then
if workTool.isTurnedOn then
workTool:setIsTurnedOn(false, false);
end;
end;
end;
if workTool.isPickupDown ~= implementsDown then
workTool:setPickup(implementsDown)
end;
if not workTool.attachablePTO.attached then
workTool:togglePTOAttach(true);
end;
if workTool.isSupportDown then
workTool:toggleSupport(false);
end;
--SPARE NETS
if not workTool.coverEdge.isLoaded then
allowedToDrive = false;
if workTool.balerUnloadingState == Baler.UNLOADING_CLOSED then
if workTool.coverEdge.hasSpareNet then --set spare net to current net
if not workTool.doors.rear.isOpen then
courseplay.thirdParty.JD864PremiumOpenRearDoor(workTool, true);
else
workTool:setHasNet(true);
courseplay.thirdParty.JD864PremiumOpenRearDoor(workTool, false, true);
end;
else --open doors for additional net supply
if workTool.isTurnedOn then
workTool:setIsTurnedOn(false);
end;
courseplay:setGlobalInfoText(self, 'BALER_NETS');
if not workTool.doors.rear.isOpen then
courseplay.thirdParty.JD864PremiumOpenRearDoor(workTool, true);
elseif workTool.coverEdge.palletInRange ~= nil and workTool.coverEdge.palletInRange.rollsLeft > 0 then
workTool:setHasSpareNet(true); --1st spare roll
workTool.coverEdge.palletInRange:removeRoll(workTool.coverEdge.palletInRange.rollsLeft-1);
workTool:setHasNet(true); --move spare to active
if workTool.coverEdge.palletInRange.rollsLeft > 0 then
workTool:setHasSpareNet(true); --2nd spare roll
workTool.coverEdge.palletInRange:removeRoll(workTool.coverEdge.palletInRange.rollsLeft-1);
end;
courseplay.thirdParty.JD864PremiumOpenRearDoor(workTool, false, true);
end;
return true, allowedToDrive;
end;
end;
end;
end;
--speed regulation
if workTool.isBlocked then
allowedToDrive = false;
courseplay:setGlobalInfoText(self, 'PICKUP_JAMMED');
end;
workTool.blockMaxTime = 10000
if workTool.actLoad2 == 1 then
if workTool.blockTimer > workTool.blockMaxTime *0.8 then
self.cp.maxFieldSpeed = self.cp.maxFieldSpeed * 0.7;
allowedToDrive = false
end
end
local actLoadSend;
if workTool.actLoad_IntSend ~= nil then
actLoadSend = workTool.actLoad_IntSend;
elseif workTool.actLoad_Send ~= nil then
actLoadSend = workTool.actLoad_Send;
end;
if actLoadSend ~= nil then
if actLoadSend < 0.8 and not workTool.isBlocked and actLoadSend ~= 0 then
self.cp.maxFieldSpeed = self.cp.maxFieldSpeed + 0.02/3600
end
if actLoadSend == 0 and self.cp.maxFieldSpeed == 0 then
self.cp.maxFieldSpeed = 4/3600
end
if actLoadSend > 0.9 and self.cp.maxFieldSpeed > 1/3600 then
self.cp.maxFieldSpeed = self.cp.maxFieldSpeed - 0.05/3600
end
end;
--speed regulation END
end;
if workTool.cp.isClaasQuadrant1200 then
return true, allowedToDrive;
else
if not unfold then
return true, allowedToDrive;
else
return false, allowedToDrive;
end;
end;
--Ursus Z586 BaleWrapper
elseif workTool.cp.isUrsusZ586 then
if workTool.baleWrapperState == 4 then
workTool:doStateChange(5)
end
if workTool.baleWrapperState ~= 0 then
allowedToDrive = false
end
return false ,allowedToDrive
--JF_FCT1060_ProTec
elseif workTool.cp.isJF1060 then
if unfold ~= nil and turnOn ~= nil and lower ~= nil then
if unfold ~= workTool.isArmOneOn and not workTool.isTurnedOn then
workTool:setArmOne(unfold);
end
if unfold ~= workTool.isTransRotOn and not workTool.isTurnedOn then
workTool:setTransRot(unfold);
end
if workTool.isTurnedOn then
workTool:setPickup(lower);
end
if workTool.isTransRotOn and workTool.isArmOneOn then
workTool:setIsTurnedOn(unfold);
end
end
local targetTrailer = workTool:findAutoAimTrailerToUnload(workTool.currentFruitType);
local trailer, trailerDistance = workTool:findTrailerToUnload(workTool.currentFruitType);
if targetTrailer == nil or trailer == nil then
allowedToDrive = false
end
return true ,allowedToDrive
--Abbey 3000 NurseTanker
elseif workTool.cp.isAbbey3000Nurse then
local x,y,z = getRotation(workTool.boomArmY)
local a,b,c = getRotation(workTool.boomArmX)
if unload ~= nil then
if unload then
if y >= -1.56 then
workTool.isEntered = true
InputBinding.actions[InputBinding.BOOM_RIGHT].lastIsPressed = true
else
workTool.isEntered = false
end
if workTool.isSpreaderInRange ~= nil then
local fillable = workTool.isSpreaderInRange
local fillableHasAttacherVehicle = fillable.attacherVehicle ~= nil;
if fillableHasAttacherVehicle then
fillable.attacherVehicle.cp.stopForLoading = true;
end;
if fillable.fillLevel >= fillable.capacity or workTool.fillLevel <= 5 then
workTool:setIsTurnedOn(false)
if fillableHasAttacherVehicle then
fillable.attacherVehicle.cp.stopForLoading = false
fillable.attacherVehicle.wait = false
end;
elseif not workTool.isTurnedOn then
workTool:setIsTurnedOn(true)
end
end
else
if y < -0.01 then
workTool.isEntered = true
InputBinding.actions[InputBinding.BOOM_LEFT].lastIsPressed = true
elseif y > 0.01 then
workTool.isEntered = true
InputBinding.actions[InputBinding.BOOM_RIGHT].lastIsPressed = true
elseif a < -0.00 then
workTool.isEntered = true
InputBinding.actions[InputBinding.BOOM_DOWN].lastIsPressed = true
else
workTool.isEntered = false
end
end
end
return true, allowedToDrive
--Abbey 2000/3000R
elseif workTool.cp.isAbbey3000R or workTool.cp.isAbbey2000R then
if workTool.PTOId then
workTool:setPTO(false)
end
if cover ~= nil then
local Cover = -1
if cover then
Cover = 1
end
workTool:setFoldDirection(Cover);
end
if lower ~= nil and turnOn ~= nil then
if workTool.setIsTurnedOn ~= nil and not workTool.isTurnedOn then
workTool:setIsTurnedOn(implementsDown, false);
end
if workTool.setIsTurnedOn ~= nil and workTool.isTurnedOn and not spray then
workTool:setIsTurnedOn(implementsDown, false);
end
end
return true, allowedToDrive
--Abbey AP900 workwith 5.8m offset-4,1m
elseif workTool.cp.isAbbeyAP900 then
if workTool.PTOId then
workTool:setPTO(false)
end
if unfold == true then
if workTool.animationParts[1].currentPosition <= 3001 then
workTool:setAnimationTime(1, workTool.animationParts[1].currentPosition+(workTool.animationParts[1].offSet*(3)));
end
else
if workTool.animationParts[1].currentPosition > 0 then
workTool:setAnimationTime(1, workTool.animationParts[1].currentPosition-(workTool.animationParts[1].offSet*(3)));
end
end
return false, allowedToDrive
--gueldnerG40Frontloader free DLC classics
elseif workTool.animatedFrontloader ~= nil then
workTool:releaseShovel(unfold);
--Krone Swadro 900 [NI-Modding]
elseif workTool.cp.isKroneSwadro900 then
local rfp1,rfp2 = workTool.rowerFoldingParts[1], workTool.rowerFoldingParts[2];
local _,_,z1 = getRotation(rfp1.mainPart.joint.jointNode);
local _,_,z2 = getRotation(rfp2.mainPart.joint.jointNode);
local isFolded1 = math.abs(z1/(rfp1.mainPart.minRot[3] + 0.00001)) < 0.01;
local isFolded2 = math.abs(z2/(rfp2.mainPart.minRot[3] + 0.00001)) < 0.01;
local isFolded = isFolded1 and isFolded2;
local isUnfolded1 = math.abs(z1/(rfp1.mainPart.maxRot[3] + 0.00001)) > 0.99;
local isUnfolded2 = math.abs(z2/(rfp2.mainPart.maxRot[3] + 0.00001)) > 0.99;
local isUnfolded = isUnfolded1 and isUnfolded2;