forked from SbSh-DNA-ModDing/FS22-CVT_Addon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCVT_Addon.lua
More file actions
4125 lines (3868 loc) · 220 KB
/
CVT_Addon.lua
File metadata and controls
4125 lines (3868 loc) · 220 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
-- @titel LessMotorBrakeforce Script for FarmingSimulator 2022
-- @new titel CVT_Addon Script for FarmingSimulator 2022
-- @author s4t4n
-- @credits Frvetz - ebenso ein riesen Dank an dieser Stelle!
-- @version v1.0.0.0 Release Modhub
-- @version v1.0.0.1 Small Changes(FS22 1.2.0.2)
-- @date 23/07/2022
-- @info CVTaddon Script for FarmingSimulator 2022
-- changed app to pre 23.12.2022 SbSh(s4t4n)
-- changelog Anpassung an FS22_realismAddon_gearbox von modelleicher
-- + Vario Fahrstufen und Beschleunigungsrampen
-- last change -- Vorbeifahrender Zug, in der Nähe hat kein addDamageAmount erkannt.
-- HST
-- known issue Neutral does'n sync lastDirection mp, you have to press a forward or reward directionbutton, not change direction
-- shop configuration produced call stacks
CVTaddon = {};
CVTaddon.modDirectory = g_currentModDirectory;
local modDesc = loadXMLFile("modDesc", g_currentModDirectory .. "modDesc.xml");
CVTaddon.modversion = getXMLString(modDesc, "modDesc.version");
CVTaddon.author = getXMLString(modDesc, "modDesc.author");
CVTaddon.contributor = getXMLString(modDesc, "modDesc.contributor");
source(CVTaddon.modDirectory.."events/SyncClientServerEvent.lua")
local scrversion = "0.3.0.81";
local modversion = CVTaddon.modversion; -- moddesc
local lastupdate = "08.11.23";
-- _______________________
sbshDebugOn = false -- \
debug_for_DBL = false -- \
sbshFlyDebugOn = false -- } Debug change via console commands
sbshCVTDebugOn = false -- /
sbshUpdDebugOn = false -- /
sbshUpd2DebugOn = false --/
-- ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
debugTable = false
local startetATM = false;
local vcaAWDon = false
local vcaInfoUnread = true
peakMotorTorqueOrigin = 0
-- local changeFlag = false;
function CVTaddon.prerequisitesPresent(specializations)
return true
end
function CVTaddon.registerEventListeners(vehicleType)
SpecializationUtil.registerEventListener(vehicleType, "onRegisterActionEvents", CVTaddon)
SpecializationUtil.registerEventListener(vehicleType, "onLoad", CVTaddon)
SpecializationUtil.registerEventListener(vehicleType, "onPreLoad", CVTaddon)
SpecializationUtil.registerEventListener(vehicleType, "onPostLoad", CVTaddon)
SpecializationUtil.registerEventListener(vehicleType, "saveToXMLFile", CVTaddon)
SpecializationUtil.registerEventListener(vehicleType, "onLeaveVehicle", CVTaddon)
SpecializationUtil.registerEventListener(vehicleType, "onStartMotor", CVTaddon)
SpecializationUtil.registerEventListener(vehicleType, "onUpdateTick", CVTaddon)
SpecializationUtil.registerEventListener(vehicleType, "onDraw", CVTaddon)
-- SpecializationUtil.registerEventListener(vehicleType, "addNewStoreConfig", CVTaddon)
SpecializationUtil.registerEventListener(vehicleType, "onReadStream", CVTaddon);
SpecializationUtil.registerEventListener(vehicleType, "onWriteStream", CVTaddon);
SpecializationUtil.registerEventListener(vehicleType, "onReadUpdateStream", CVTaddon);
SpecializationUtil.registerEventListener(vehicleType, "onWriteUpdateStream", CVTaddon);
addModEventListener(CVTaddon)
end
----------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------
function CVTaddon:onRegisterActionEvents()
if g_client ~= nil then
local spec = self.spec_CVTaddon
spec.BackupMaxFwSpd = tostring(self.spec_motorized.motor.maxForwardSpeedOrigin)
spec.BackupMaxBwSpd = tostring(self.spec_motorized.motor.maxBackwardSpeedOrigin)
spec.calcBrakeForce = string.format("%.2f", self.spec_motorized.motor.maxForwardSpeedOrigin/(self.spec_motorized.motor.maxForwardSpeedOrigin*math.pi)+10)
spec.maxRpmOrigin = tostring(self.spec_motorized.motor.maxRpm)
if self.getIsEntered ~= nil and self:getIsEntered() then
CVTaddon.actionEventsV1 = {}
CVTaddon.actionEventsV2 = {}
CVTaddon.actionEventsVt = {}
CVTaddon.actionEventsV3 = {}
CVTaddon.actionEventsV4 = {}
CVTaddon.actionEventsV5 = {}
CVTaddon.actionEventsV6 = {}
CVTaddon.actionEventsV7 = {}
CVTaddon.actionEventsV12 = {}
CVTaddon.actionEventsV13 = {}
CVTaddon.actionEventsV8 = {}
CVTaddon.actionEventsV9 = {}
CVTaddon.actionEventsV10 = {}
local storeItem = g_storeManager:getItemByXMLFilename(self.configFileName)
if sbshDebugOn then
print("storeItem.categoryName: " .. tostring(storeItem.categoryName)) -- debug
end
spec.currSpdCheck = self:getLastSpeed()
if sbshDebugOn then
print("CVTaddon: onRegisterActionEvents vOne: ".. tostring(spec.vOne))
print("CVTaddon: onRegisterActionEvents vTwo: ".. tostring(spec.vTwo))
print("CVTaddon: onRegisterActionEvents vThree: ".. tostring(spec.vThree))
print("CVTaddon: onRegisterActionEvents eventActiveV1: ".. tostring(CVTaddon.eventActiveV1))
print("CVTaddon: onRegisterActionEvents eventActiveV2: ".. tostring(CVTaddon.eventActiveV2))
print("CVTaddon: onRegisterActionEvents eventActiveV3: ".. tostring(CVTaddon.eventActiveV3))
print("CVTaddon: onRegisterActionEvents eventActiveV4: ".. tostring(CVTaddon.eventActiveV4))
end
-- Tasten Bindings
-- D1
_, CVTaddon.eventIdV1 = self:addActionEvent(CVTaddon.actionEventsV1, 'SETVARIOONE', self, CVTaddon.VarioOne, false, true, false, true)
g_inputBinding:setActionEventTextPriority(CVTaddon.eventIdV1, GS_PRIO_NORMAL)
g_inputBinding:setActionEventTextVisibility(CVTaddon.eventIdV1, false)
-- g_inputBinding:setActionEventTextVisibility(spec.eventIdV1, true) -- test if works
-- D2
_, CVTaddon.eventIdV2 = self:addActionEvent(CVTaddon.actionEventsV2, 'SETVARIOTWO', self, CVTaddon.VarioTwo, false, true, false, true)
g_inputBinding:setActionEventTextPriority(CVTaddon.eventIdV2, GS_PRIO_NORMAL)
g_inputBinding:setActionEventTextVisibility(CVTaddon.eventIdV2, false)
-- g_inputBinding:setActionEventTextVisibility(spec.eventIdV2, true) -- test if works
-- D toggle
_, CVTaddon.eventIdVt = self:addActionEvent(CVTaddon.actionEventsVt, 'SETVARIOTOGGLE', self, CVTaddon.VarioToggle, false, true, false, true)
g_inputBinding:setActionEventTextPriority(CVTaddon.eventIdVt, GS_PRIO_NORMAL)
g_inputBinding:setActionEventTextVisibility(CVTaddon.eventIdVt, false)
-- AR
_, CVTaddon.eventIdV3 = self:addActionEvent(CVTaddon.actionEventsV3, 'LMBF_TOGGLE_RAMP', self, CVTaddon.AccRamps, false, true, false, true)
g_inputBinding:setActionEventTextPriority(CVTaddon.eventIdV3, GS_PRIO_NORMAL)
g_inputBinding:setActionEventTextVisibility(CVTaddon.eventIdV3, false)
-- BR
_, CVTaddon.eventIdV4 = self:addActionEvent(CVTaddon.actionEventsV4, 'LMBF_TOGGLE_BRAMP', self, CVTaddon.BrakeRamps, false, true, false, true)
g_inputBinding:setActionEventTextPriority(CVTaddon.eventIdV4, GS_PRIO_NORMAL)
g_inputBinding:setActionEventTextVisibility(CVTaddon.eventIdV4, false)
-- neutral
-- _, CVTaddon.eventIdV5 = self:addActionEvent(CVTaddon.actionEventsV5, 'SETVARION', self, CVTaddon.VarioN, false, true, false, true)
-- g_inputBinding:setActionEventTextPriority(CVTaddon.eventIdV5, GS_PRIO_NORMAL)
-- g_inputBinding:setActionEventTextVisibility(CVTaddon.eventIdV5, false)
-- -- rpmUP
-- _, CVTaddon.eventIdV6 = self:addActionEvent(CVTaddon.actionEventsV6, 'SETVARIORPMP', self, CVTaddon.VarioRpmPlus, false, true, false, true)
-- g_inputBinding:setActionEventTextPriority(CVTaddon.eventIdV6, GS_PRIO_NORMAL)
-- g_inputBinding:setActionEventTextVisibility(CVTaddon.eventIdV6, CVTaddon.eventActiveV6)
-- -- rpmDn
-- _, CVTaddon.eventIdV7 = self:addActionEvent(CVTaddon.actionEventsV7, 'SETVARIORPMM', self, CVTaddon.VarioRpmMinus, false, true, false, true)
-- g_inputBinding:setActionEventTextPriority(CVTaddon.eventIdV7, GS_PRIO_NORMAL)
-- g_inputBinding:setActionEventTextVisibility(CVTaddon.eventIdV7, CVTaddon.eventActiveV7)
-- rpm axis
_, CVTaddon.eventIdV12 = self:addActionEvent(CVTaddon.actionEventsV12, 'SETVARIORPM_AXIS', self, CVTaddon.VarioRpmAxis, false, false, true, true)
g_inputBinding:setActionEventTextPriority(CVTaddon.eventIdV12, GS_PRIO_NORMAL)
g_inputBinding:setActionEventTextVisibility(CVTaddon.eventIdV12, CVTaddon.eventActiveV12)
-- clutch axis
_, CVTaddon.eventIdV13 = self:addActionEvent(CVTaddon.actionEventsV13, 'SETVARIOCLUTCH_AXIS', self, CVTaddon.VarioClutchAxis, false, false, true, true)
g_inputBinding:setActionEventTextPriority(CVTaddon.eventIdV13, GS_PRIO_NORMAL)
g_inputBinding:setActionEventTextVisibility(CVTaddon.eventIdV13, CVTaddon.eventActiveV13)
-- Fahrpedalauflösung -- needed? oder ändern in RPM aka gearbox
_, CVTaddon.eventIdV8 = self:addActionEvent(CVTaddon.actionEventsV8, 'SETPEDALTMS', self, CVTaddon.VarioPedalRes, false, true, false, true)
g_inputBinding:setActionEventTextPriority(CVTaddon.eventIdV8, GS_PRIO_NORMAL)
g_inputBinding:setActionEventTextVisibility(CVTaddon.eventIdV8, false)
-- autoDiffs
_, CVTaddon.eventIdV9 = self:addActionEvent(CVTaddon.actionEventsV9, 'SETVARIOADIFFS', self, CVTaddon.VarioADiffs, false, true, false, true)
g_inputBinding:setActionEventTextPriority(CVTaddon.eventIdV9, GS_PRIO_NORMAL)
g_inputBinding:setActionEventTextVisibility(CVTaddon.eventIdV9, false)
-- rpmDmax
_, CVTaddon.eventIdV10 = self:addActionEvent(CVTaddon.actionEventsV10, 'SETVARIORPMDMAX', self, CVTaddon.VarioRpmDmax, false, true, false, true)
g_inputBinding:setActionEventTextPriority(CVTaddon.eventIdV10, GS_PRIO_NORMAL)
g_inputBinding:setActionEventTextVisibility(CVTaddon.eventIdV10, CVTaddon.eventActiveV10)
end
if sbshDebugOn then
print("CVTaddon: onRegisterActionEvents a vOne: ".. tostring(spec.vOne))
print("CVTaddon: onRegisterActionEvents a vTwo: ".. tostring(spec.vTwo))
print("CVTaddon: onRegisterActionEvents a vThree: ".. tostring(spec.vThree))
print("CVTaddon: onRegisterActionEvents a vFour: ".. tostring(spec.vFour))
print("CVTaddon: onRegisterActionEvents a eventActiveV1: ".. tostring(CVTaddon.eventActiveV1))
print("CVTaddon: onRegisterActionEvents a eventActiveV2: ".. tostring(CVTaddon.eventActiveV2))
print("CVTaddon: onRegisterActionEvents a eventActiveV3: ".. tostring(CVTaddon.eventActiveV3))
print("CVTaddon: onRegisterActionEvents a eventActiveV4: ".. tostring(CVTaddon.eventActiveV4))
end
end -- g_client
end -- onRegisterActionEvents
-- function CVTaddon.registerSoundXMLPaths(schema, baseKey)
-- SoundManager.registerSampleXMLPaths(schema, baseKey, "motorFAN")
-- end
function CVTaddon:onLoad()
-- if g_client ~= nil then
self.spec_CVTaddon = {}
local spec = self.spec_CVTaddon
local pcspec = self.spec_powerConsumer
-- HUD Grafiken laden
spec.CVTIconBg = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDbg.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconFb = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDfb.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconFs1 = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDfs1.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconFs2 = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDfs2.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconPtms = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDptms.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconHg2 = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDhg2.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconHg3 = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDhg3.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconHg4 = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDhg4.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconHg5 = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDhg5.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconHEAT = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDpto.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconDmg = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDpto.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconHg6 = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDhg6.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconHg7 = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDhg7.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconHg8 = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDhg8.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconHg9 = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDhg9.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconHg10 = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDhg10.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconAr1 = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDar1.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconAr2 = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDar2.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconAr3 = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDar3.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconAr4 = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDar4.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconBr1 = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDbr1.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconBr2 = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDbr2.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconBr3 = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDbr3.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconBr4 = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDbr4.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconHydro = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDhydro.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
-- spec.CVTIconN = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDn.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconN2 = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDn2.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconR = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDr.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.CVTIconV = Overlay.new(Utils.getFilename("hud/CVTaddon_HUDv.dds", CVTaddon.modDirectory), 0, 0, 1, 1);
spec.BG1width, spec.BG1height = 0.005, 0.09;
spec.currBGcolor = { 0.02, 0.02, 0.02, 0.7 }
if self.spec_motorized.motor.currentDirection == nil then
spec.lastDirection = 1
end
-- defaults if allother nil
spec.smoother = 0
spec.vOne = 1
spec.vTwo = 4
spec.vThree = 2
spec.vFour = 1
spec.vFive = 0
spec.HandgasPercent = 0
spec.ClutchInputValue = 0
spec.autoDiffs = 0
spec.lastDirection = 1
spec.isTMSpedal = 0
spec.moveRpmL = 0
spec.impIsLowered = false
spec.rpmrange = 1
-- spec.rpmDmin
spec.rpmDmax = self.spec_motorized.motor.maxRpm
spec.BlinkTimer = 0
spec.NumberBlinkTimer = 0
spec.Counter = 0
spec.AN = false
spec.CVTconfig = 0
spec.CVTcfgExists = false
spec.CVTdamage = 0.000
-- spec.RpmInputValue = 0
-- spec.mcRPMvar = 1
-- to make it easier read with dashbord-live
spec.forDBL_pedalpercent = tostring(self.spec_motorized.motor.lastAcceleratorPedal*100)
spec.forDBL_rpmrange = tostring(spec.rpmDmax .. " - " .. self.spec_motorized.motor.minRpm)
spec.forDBL_rpmDmin = tostring(0)
spec.forDBL_autoDiffs = tostring(0)
spec.forDBL_IPMactive = tostring(0)
spec.forDBL_brakeramp = tostring(0)
spec.forDBL_warnHeat = 0
spec.forDBL_warnDamage = 0
spec.forDBL_critHeat = 0
spec.forDBL_critDamage = 0
spec.forDBL_CVTdamage = 0.000
if spec.vFour ~= nil then
if spec.isTMSpedal == 0 then
spec.forDBL_tmspedal = 0
elseif spec.isTMSpedal == 1 then
spec.forDBL_tmspedal = 1
end
end
if spec.vFour ~= nil then
if spec.vFour == 0 then
spec.forDBL_neutral = 1
elseif spec.vFour == 1 then
spec.forDBL_neutral = 0
end
end
if spec.vOne ~= nil then
if spec.vOne == 1 then
spec.forDBL_drivinglevel = tostring(2)
elseif spec.vOne == 2 then
spec.forDBL_drivinglevel = tostring(1)
end
end
spec.forDBL_digitalhandgasstep = tostring(spec.vFive)
if spec.vTwo ~= nil then
if spec.vTwo == 1 then
spec.forDBL_accramp = tostring(4)
elseif spec.vTwo == 2 then
spec.forDBL_accramp = tostring(1)
elseif spec.vTwo == 3 then
spec.forDBL_accramp = tostring(2)
elseif spec.vTwo == 4 then
spec.forDBL_accramp = tostring(3)
end
end
spec.forDBL_rpmDmax = tostring(spec.rpmDmax)
if spec.vThree ~= nil then
if (spec.vThree == 1) then -- BRamp 1
spec.forDBL_brakeramp = tostring(17) -- off
end
if (spec.vThree == 2) then -- BRamp 2
spec.forDBL_brakeramp = tostring(0) -- km/h
end
if (spec.vThree == 3) then -- BRamp 3
spec.forDBL_brakeramp = tostring(4) -- km/h
end
if (spec.vThree == 4) then -- BRamp 4
spec.forDBL_brakeramp = tostring(8) -- km/h
end
if (spec.vThree == 5) then -- BRamp 5
spec.forDBL_brakeramp = tostring(15) -- km/h
end
end
-- spec.forDBL_
CVTaddon.eventActiveV1 = true
CVTaddon.eventActiveV2 = true
CVTaddon.eventActiveVt = true
CVTaddon.eventActiveV3 = true
CVTaddon.eventActiveV4 = true
CVTaddon.eventActiveV5 = true
CVTaddon.eventActiveV6 = true
CVTaddon.eventActiveV7 = true
CVTaddon.eventActiveV12 = true
CVTaddon.eventActiveV13 = true
CVTaddon.eventActiveV8 = true
CVTaddon.eventActiveV9 = true
CVTaddon.eventActiveV10 = true
CVTaddon.eventIdV1 = nil
CVTaddon.eventIdV2 = nil
CVTaddon.eventIdVt = nil
CVTaddon.eventIdV3 = nil
CVTaddon.eventIdV4 = nil
CVTaddon.eventIdV5 = nil
CVTaddon.eventIdV6 = nil
CVTaddon.eventIdV7 = nil
CVTaddon.eventIdV12 = nil
CVTaddon.eventIdV13 = nil
CVTaddon.eventIdV8 = nil
CVTaddon.eventIdV9 = nil
CVTaddon.eventIdV10 = nil
spec.BackupMaxFwSpd = ""
if spec.calcBrakeForce == nil then
spec.calcBrakeForce = "0.5"
end
spec.dirtyFlag = self:getNextDirtyFlag()
spec.check = false
end -- onLoad
-----------------------------------------------------------------------------------------------
function CVTaddon.initSpecialization()
local schemaSavegame = Vehicle.xmlSchemaSavegame
schemaSavegame:register(XMLValueType.BOOL, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#eventActiveV1")
schemaSavegame:register(XMLValueType.BOOL, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#eventActiveV2")
schemaSavegame:register(XMLValueType.BOOL, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#eventActiveVt")
schemaSavegame:register(XMLValueType.BOOL, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#eventActiveV3")
schemaSavegame:register(XMLValueType.BOOL, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#eventActiveV4")
schemaSavegame:register(XMLValueType.BOOL, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#eventActiveV5")
schemaSavegame:register(XMLValueType.BOOL, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#eventActiveV6")
schemaSavegame:register(XMLValueType.BOOL, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#eventActiveV7")
schemaSavegame:register(XMLValueType.BOOL, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#eventActiveV8")
schemaSavegame:register(XMLValueType.BOOL, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#eventActiveV9")
schemaSavegame:register(XMLValueType.BOOL, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#eventActiveV10")
schemaSavegame:register(XMLValueType.INT, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#vOne")
schemaSavegame:register(XMLValueType.INT, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#vTwo")
schemaSavegame:register(XMLValueType.INT, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#vThree")
schemaSavegame:register(XMLValueType.INT, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#vFour")
schemaSavegame:register(XMLValueType.INT, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#vFive")
schemaSavegame:register(XMLValueType.INT, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#lastDirection")
-- schemaSavegame:register(XMLValueType.INT, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#PedalResolution")
schemaSavegame:register(XMLValueType.INT, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#rpmDmax")
schemaSavegame:register(XMLValueType.INT, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#autoDiffs")
schemaSavegame:register(XMLValueType.INT, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#configurationId")
schemaSavegame:register(XMLValueType.FLOAT, "vehicles.vehicle(?).FS22_CVT_Addon.CVTaddon#CVTdamage")
print("CVT_Addon: initialized...... ")
print("CVT_Addon: by " .. CVTaddon.author .. " and awsome contributor " .. CVTaddon.contributor)
print("CVT_Addon: Script-Version...: " .. scrversion)
print("CVT_Addon: Mod-Version......: " .. modversion)
print("CVT-Addon: Date.............: " .. lastupdate)
end -- initSpecialization
function CVTaddon:onPreLoad(savegame)
local spec = self.spec_CVTaddon
local configurationId = Utils.getNoNil(self.configurations["CVTaddon"], 0)
-- print("CVTa: onPreLoad configurationId noNIL " .. configurationId)
if savegame ~= nil then
if configurationId > 0 then
configurationId = savegame.xmlFile:getValue(savegame.key .. ".FS22_CVT_Addon.CVTaddon#configurationId", configurationId)
-- if configurationId < 1 or configurationId > 8 then
-- configurationId = 1
-- end
self.configurations["CVTaddon"] = configurationId
-- print("CVTa: onPreLoad configurationId " .. configurationId)
end
-- print("CVTa: onPreLoad configurationId out " .. configurationId)
end
end
function initNewStoreConfig()
print("CVTaREG: initNewStoreConfig")
g_configurationManager:addConfigurationType("CVTaddon", g_i18n:getText("text_CVT_title"), nil, nil, nil, nil, ConfigurationUtil.SELECTOR_MULTIOPTION)
StoreItemUtil.getConfigurationsFromXML = Utils.overwrittenFunction(StoreItemUtil.getConfigurationsFromXML, addNewStoreConfig)
end
function addNewStoreConfig(xmlFile, superFunc, baseXMLName, baseDir, customEnvironment, isMod, storeItem)
local configurations = superFunc(xmlFile, baseXMLName, baseDir, customEnvironment, isMod, storeItem)
-- local spec = self.spec_CVTaddon
local StI = ""
if storeItem == nil then
--
elseif configurations == nil then
--
elseif configurations["CVTaddon"] ~= nil then
--
else
-- StI = string.sub(storeItem.categoryName, 1, 8)
StI = storeItem.categoryName
end
local addXtraCats = string.find(tostring(StI), "sdf") or string.find(tostring(StI), "SDF") or string.find(tostring(StI), "LSFM")
local int2ndVehicles = StI == "GRAPEVEHICLES" or StI == "OLIVEVEHICLES" or StI == "FORAGEHARVESTERCUTTERS" or StI == "MOWERVEHICLES" or StI == "SLURRYVEHICLES"
local intVehicles = addXtraCats or StI == "TRACTORSS" or StI == "TRACTORSM" or StI == "TRACTORSL" or StI == "HARVESTERS" or StI == "FORAGEHARVESTERS" or StI == "POTATOVEHICLES" or StI == "BEETVEHICLES" or StI == "SUGARCANEVEHICLES" or StI == "COTTONVEHICLES" or StI == "MISCVEHICLES" or StI == "FRONTLOADERVEHICLES" or StI == "TELELOADERVEHICLES" or StI == "SKIDSTEERVEHICLES" or StI == "WHEELLOADERVEHICLES" or StI == "WOODHARVESTING" or StI == "FORKLIFTS" or StI == "ANIMALSVEHICLES"
-- print("CVTa ShopCat: " .. tostring(StI))
if intVehicles or int2ndVehicles then
local xmlFile = XMLFile.load("vehicle", storeItem.xmlFilename, Vehicle.xmlSchema)
local isVario = true -- ToDo: find a way to check if one of a motorconfig has cvt, when the first one is a manual shift
local manualShift = getXMLString(xmlFile.handle, "vehicle.motorized.motorConfigurations.motorConfiguration(?).transmission(?)#name")
local modNamez = getXMLString(xmlFile.handle, "vehicle.storeData.name")
-- local specspower = getXMLString(xmlFile.handle, "vehicle.storeData.specs.power")
-- print("CVTa modName: " .. tostring(modNamez))
-- print("CVTa specspower: " .. tostring(specspower))
-- print("CVTa Getriebename: " .. tostring(manualShift))
if string.find(tostring(manualShift), "cvt") or string.find(tostring(manualShift), "cvx") or string.find(tostring(manualShift), "vario") or string.find(tostring(manualShift), "stufenlos") or string.find(tostring(manualShift), "auto") then
isVario = true
end
local integrateConfig = true
if storeItem.isMod == false then
if StI == "TRUCKS" then
integrateConfig = false
end
else
if StI == "TRUCKS" then
local modName = getXMLString(xmlFile.handle, "vehicle.storeData.name")
if modName == nil then
modName = getXMLString(xmlFile.handle, "vehicle.storeData.name.en")
end
if modName == nil then
integrateConfig = false
elseif string.find(string.upper(modName), "UNIMOG") == nil then
integrateConfig = false
end
if modName == "$l10n_storeData_name_1axis" then -- Unimog U5023
integrateConfig = true
end
if modName == "E - Locomotive" or modName == "locomotive" or modName == "horse" then
integrateConfig = false
end
-- print("CVTa modName: " .. tostring(modName))
end
end
delete(xmlFile.handle)
if isVario == true and integrateConfig == true then
local name1 = g_i18n:getText("text_CVTclas_installed_short")
local name2 = g_i18n:getText("text_CVTclasB1_installed_short")
local name3 = g_i18n:getText("text_CVTclasB2_installed_short")
local name4 = g_i18n:getText("text_CVTmod_installed_short")
local name5 = g_i18n:getText("text_CVTmodB1_installed_short")
local name6 = g_i18n:getText("text_CVTmodB2_installed_short")
local name7 = g_i18n:getText("text_HST_installed_short")
local name8 = g_i18n:getText("text_CVT_notInstalled_short")
-- local name9 = "manuell"
configurations["CVTaddon"] = {
{name = name1, index = 1, isDefault = false, price = 0, dailyUpkeep = 0, isSelectable = true},
{name = name2, index = 2, isDefault = false, price = 750, dailyUpkeep = 0, isSelectable = true},
{name = name3, index = 3, isDefault = false, price = 1000, dailyUpkeep = 0, isSelectable = true},
{name = name4, index = 4, isDefault = false, price = 0, dailyUpkeep = 0, isSelectable = true},
{name = name5, index = 5, isDefault = false, price = 750, dailyUpkeep = 0, isSelectable = true},
{name = name6, index = 6, isDefault = false, price = 1000, dailyUpkeep = 0, isSelectable = true},
{name = name7, index = 7, isDefault = false, price = 0, dailyUpkeep = 5, isSelectable = true},
{name = name8, index = 8, isDefault = false, price = 0, dailyUpkeep = 0, isSelectable = true}
}
end
end
return configurations
end
if g_configurationManager.configurations["CVTaddon"] == nil then
initNewStoreConfig()
print("CVTa: init store config")
end
function CVTaddon:onPostLoad(savegame)
local spec = self.spec_CVTaddon
local configurationId = Utils.getNoNil(self.configurations["CVTaddon"], 0)
if g_client ~= nil then
if self.spec_motorized ~= nil then
if spec == nil then return end
spec.CVTcfgExists = self.configurations["CVTaddon"] ~= nil and self.configurations["CVTaddon"] ~= 0
if savegame ~= nil then
local xmlFile = savegame.xmlFile
local key = savegame.key .. ".FS22_CVT_Addon.CVTaddon"
spec.vOne = xmlFile:getValue(key.."#vOne", spec.vOne)
spec.vTwo = xmlFile:getValue(key.."#vTwo", spec.vTwo)
spec.vThree = xmlFile:getValue(key.."#vThree", spec.vThree)
spec.vFour = xmlFile:getValue(key.."#vFour", spec.vFour)
spec.vFive = xmlFile:getValue(key.."#vFive", spec.vFive)
spec.autoDiffs = xmlFile:getValue(key.."#autoDiffs", spec.autoDiffs)
spec.lastDirection = xmlFile:getValue(key.."#lastDirection", spec.lastDirection)
-- spec.PedalResolution = xmlFile:getValue(key.."#PedalResolution", spec.PedalResolution)
spec.rpmDmax = xmlFile:getValue(key.."#rpmDmax", spec.rpmDmax)
spec.CVTconfig = xmlFile:getValue(key.."#configurationId", spec.CVTconfig)
spec.CVTdamage = xmlFile:getValue(key.."#CVTdamage", spec.CVTdamage)
print("CVT_Addon: personal adjustments loaded for "..self:getName())
print("CVT_Addon: Load Driving Level id: "..tostring(spec.vOne))
print("CVT_Addon: Load Acceleration Ramp id: "..tostring(spec.vTwo))
print("CVT_Addon: Load Brake Ramp id: "..tostring(spec.vThree))
end
end
end -- g_client
-- self.configurations["CVTaddon"] = spec.CVTcfgExists and 7 or 6 or 5 or 4 or 3 or 2 or 1
-- self.configurations["CVTaddon"] = spec.CVTconfig and 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8
if spec.CVTcfgExists then
-- self.configurations["CVTaddonConfigs"] = spec.CVTconfig
spec.CVTconfig = configurationId
-- print("CVTa: if spec.CVTcfgExists then : " .. tostring(spec.CVTcfgExists))
-- print("CVTa: configurationId: " .. configurationId)
-- print("CVTa: CVTconfig: " .. tostring(spec.CVTconfig))
-- print("CVTa: isVarioTM PL: " .. tostring(spec.isVarioTM))
end
-- gU_targetSelf = self
-- print("CVTa: configurationId safe hlm " .. configurationId)
-- print("CVTa: configurationId spec.CVTconfig " .. spec.CVTconfig)
-- if spec.CVTconfig == nil or 0 then
-- spec.CVTconfig = configurationId
-- end
-- to make it easier read with dashbord-live
spec.forDBL_pedalpercent = tostring(self.spec_motorized.motor.lastAcceleratorPedal*100)
spec.forDBL_rpmrange = 1
spec.forDBL_rpmDmin = tostring(0)
spec.forDBL_autoDiffs = tostring(0)
spec.forDBL_IPMactive = tostring(0)
spec.forDBL_brakeramp = tostring(0)
spec.forDBL_warnHeat = 0
spec.forDBL_warnDamage = 0
spec.forDBL_critHeat = 0
spec.forDBL_critDamage = 0
if spec.CVTdamage ~= nil then
spec.forDBL_CVTdamage = spec.CVTdamage
else
spec.forDBL_CVTdamage = 0.00
spec.CVTdamage = 0.000
end
-- if spec.vFour ~= nil then
if spec.isTMSpedal ~= nil then
if spec.isTMSpedal == 0 then
spec.forDBL_tmspedal = 0
elseif spec.isTMSpedal == 1 then
spec.forDBL_tmspedal = 1
end
end
if spec.vFour ~= nil then
if spec.vFour == 0 then
spec.forDBL_neutral = 1
elseif spec.vFour == 1 then
spec.forDBL_neutral = 0
end
end
if spec.vOne ~= nil then
if spec.vOne == 1 then
spec.forDBL_drivinglevel = tostring(2)
elseif spec.vOne == 2 then
spec.forDBL_drivinglevel = tostring(1)
end
end
spec.forDBL_digitalhandgasstep = tostring(spec.vFive)
if spec.vTwo ~= nil then
if spec.vTwo == 1 then
spec.forDBL_accramp = tostring(4)
elseif spec.vTwo == 2 then
spec.forDBL_accramp = tostring(1)
elseif spec.vTwo == 3 then
spec.forDBL_accramp = tostring(2)
elseif spec.vTwo == 4 then
spec.forDBL_accramp = tostring(3)
end
end
spec.forDBL_rpmDmax = tostring(spec.rpmDmax)
if spec.vThree ~= nil then
if (spec.vThree == 1) then -- BRamp 1
spec.forDBL_brakeramp = tostring(17) -- off
end
if (spec.vThree == 2) then -- BRamp 2
spec.forDBL_brakeramp = tostring(0) -- km/h
end
if (spec.vThree == 3) then -- BRamp 3
spec.forDBL_brakeramp = tostring(4) -- km/h
end
if (spec.vThree == 4) then -- BRamp 4
spec.forDBL_brakeramp = tostring(8) -- km/h
end
if (spec.vThree == 5) then -- BRamp 5
spec.forDBL_brakeramp = tostring(15) -- km/h
end
end
-- spec.forDBL_
end -- onPostLoad
function CVTaddon:saveToXMLFile(xmlFile, key, usedModNames)
if self.spec_motorized ~= nil then
local spec = self.spec_CVTaddon
-- if spec.CVTconfig ~= nil or spec.CVTconfig ~= 0
spec.CVTconfig = self.configurations["CVTaddon"] or 1
-- #configPart
-- spec.cvtexists = self.configurations["CVTaddon"] == 2
-- spec.actionsLength = table.getn(spec.actions)
if spec.isVarioTM then
xmlFile:setValue(key.."#vOne", spec.vOne)
xmlFile:setValue(key.."#vTwo", spec.vTwo)
xmlFile:setValue(key.."#vThree", spec.vThree)
xmlFile:setValue(key.."#vFour", spec.vFour)
xmlFile:setValue(key.."#vFive", spec.vFive)
xmlFile:setValue(key.."#autoDiffs", spec.autoDiffs)
xmlFile:setValue(key.."#lastDirection", spec.lastDirection)
-- xmlFile:setValue(key.."#PedalResolution", spec.PedalResolution)
-- xmlFile:setValue(key.."#rpmDmin", spec.rpmDmin)
xmlFile:setValue(key.."#rpmDmax", spec.rpmDmax)
xmlFile:setValue(key.."#configurationId", spec.CVTconfig)
xmlFile:setValue(key.."#CVTdamage", spec.CVTdamage)
end
print("CVT_Addon: saved.")
-- print("CVT_Addon: saved personal adjustments for "..self:getName())
-- print("CVT_Addon: Save Driving Level id: "..tostring(spec.vOne))
-- print("CVT_Addon: Save Acceleration Ramp id: "..tostring(spec.vTwo))
-- print("CVT_Addon: Save Brake Ramp id: "..tostring(spec.vThree))
-- print("CVT_Addon: Save CfgID: "..tostring(spec.CVTconfig))
end
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
function CVTaddon:VarioRpmDmax() -- RPM range max
local spec = self.spec_CVTaddon
-- spec.maxRpmOrigin = self.spec_motorized.motor.maxRpm
if g_client ~= nil then
if sbshDebugOn then
print("VarioRpmDmax rpmrange: "..tostring(spec.rpmrange))
print("VarioRpmDmax Taste gedrückt: "..tostring(spec.rpmDmax))
print("maxRpmOrigin: "..tostring(spec.maxRpmOrigin))
end
if self.CVTaddon == nil then
return
end
if not CVTaddon.eventActiveV10 then
return
end
if (spec.rpmrange == 1) then -- full / off
if sbshDebugOn then
print("VarioRpmDmax rpmrange 1: "..tostring(spec.rpmrange))
print("VarioRpmDmax Taste gedrückt 1: "..tostring(spec.rpmDmax))
print("maxRpmOrigin 1: "..tostring(spec.maxRpmOrigin))
end
print("VarioRpmDmax rpmrange 1: "..tostring(spec.rpmrange))
print("VarioRpmDmax full pwr")
end
if (spec.rpmrange == 2) then -- reduce 1
if sbshDebugOn then
print("VarioRpmDmax rpmrange 2: "..tostring(spec.rpmrange))
print("VarioRpmDmax Taste gedrückt 2: "..tostring(spec.rpmDmax))
print("maxRpmOrigin 2: "..tostring(spec.maxRpmOrigin))
end
print("VarioRpmDmax rpmrange 2: "..tostring(spec.rpmrange))
print("VarioRpmDmax Eco field")
end
if (spec.rpmrange == 3) then -- reduce 2
if sbshDebugOn then
print("VarioRpmDmax rpmrange 3: "..tostring(spec.rpmrange))
print("VarioRpmDmax Taste gedrückt 3: "..tostring(spec.rpmDmax))
print("maxRpmOrigin 3: "..tostring(spec.maxRpmOrigin))
end
print("VarioRpmDmax rpmrange 3: "..tostring(spec.rpmrange))
print("VarioRpmDmax Eco1")
end
if (spec.rpmrange == 4) then -- reduce 3
if sbshDebugOn then
print("VarioRpmDmax rpmrange 4: "..tostring(spec.rpmrange))
print("VarioRpmDmax Taste gedrückt 4: "..tostring(spec.rpmDmax))
print("maxRpmOrigin 4: "..tostring(spec.maxRpmOrigin))
end
print("VarioRpmDmax rpmrange 4: "..tostring(spec.rpmrange))
print("VarioRpmDmax Eco2")
end
if spec.rpmrange == 4 or spec.rpmrange == nil then
spec.rpmrange = 1
else
spec.rpmrange = spec.rpmrange + 1
end
if sbshDebugOn then
print("VarioRpmDmax rpmrange E: "..tostring(spec.rpmrange))
print("VarioRpmDmax Taste gedrückt E: "..tostring(spec.rpmDmax))
print("maxRpmOrigin E: "..tostring(spec.maxRpmOrigin))
end
spec.forDBL_rpmDmax = tostring(spec.rpmDmax)
self:raiseDirtyFlags(spec.dirtyFlag)
if g_server ~= nil then
g_server:broadcastEvent(SyncClientServerEvent.new(self, spec.vOne, spec.vTwo, spec.vThree, spec.vFour, spec.vFive, spec.autoDiffs, spec.lastDirection, spec.isVarioTM, spec.isTMSpedal, spec.moveRpmL, spec.rpmDmax, spec.rpmrange, spec.CVTconfig, spec.forDBL_warnHeat, spec.forDBL_critHeat, spec.forDBL_warnDamage, spec.forDBL_critDamage, spec.CVTdamage, spec.HandgasPercent, spec.ClutchInputValue), nil, nil, self)
else
g_client:getServerConnection():sendEvent(SyncClientServerEvent.new(self, spec.vOne, spec.vTwo, spec.vThree, spec.vFour, spec.vFive, spec.autoDiffs, spec.lastDirection, spec.isVarioTM, spec.isTMSpedal, spec.moveRpmL, spec.rpmDmax, spec.rpmrange, spec.CVTconfig, spec.forDBL_warnHeat, spec.forDBL_critHeat, spec.forDBL_warnDamage, spec.forDBL_critDamage, spec.CVTdamage, spec.HandgasPercent, spec.ClutchInputValue))
end
end -- g_client
end -- rpmDmin
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
function CVTaddon:BrakeRamps() -- BREMSRAMPEN - Ab kmh X wird die Betriebsbremse automatisch aktiv
local spec = self.spec_CVTaddon
if g_client ~= nil then
-- local spec = self.spec_CVTaddon
if sbshDebugOn then
print("BrRamp Taste gedrückt vThree: "..tostring(spec.vThree))
print("BrRamp Taste gedrückt lBFSL: "..self.spec_motorized.motor.lowBrakeForceSpeedLimit)
end
if self.CVTaddon == nil then
return
end
if not CVTaddon.eventActiveV4 then
return
end
if (spec.vThree == 1) then -- BRamp 1
spec.forDBL_brakeramp = tostring(0) -- off / 1-2 km/h vanilla lowBrakeForceSpeedLimit: 0.00027777777777778
if sbshDebugOn then
print("BrRamp 1 vThree: "..tostring(spec.vThree))
print("BrRamp 1 lBFSL: "..self.spec_motorized.motor.lowBrakeForceSpeedLimit)
end
end
if (spec.vThree == 2) then -- BRamp 2
spec.forDBL_brakeramp = tostring(4) -- km/h
if sbshDebugOn then
print("BrRamp 2 vThree: "..tostring(spec.vThree))
print("BrRamp 2 lBFSL: "..self.spec_motorized.motor.lowBrakeForceSpeedLimit)
end
end
if (spec.vThree == 3) then -- BRamp 3
spec.forDBL_brakeramp = tostring(8) -- km/h
if sbshDebugOn then
print("BrRamp 3 vThree: "..tostring(spec.vThree))
print("BrRamp 3 lBFSL: "..self.spec_motorized.motor.lowBrakeForceSpeedLimit)
end
end
if (spec.vThree == 4) then -- BRamp 4
spec.forDBL_brakeramp = tostring(15) -- km/h
if sbshDebugOn then
print("BrRamp 4 vThree: "..tostring(spec.vThree))
print("BrRamp 4 lBFSL: "..self.spec_motorized.motor.lowBrakeForceSpeedLimit)
end
end
if (spec.vThree == 5) then -- BRamp 5
spec.forDBL_brakeramp = tostring(17) -- km/h
if sbshDebugOn then
print("BrRamp 5 vThree: "..tostring(spec.vThree))
print("BrRamp 5 lBFSL: "..self.spec_motorized.motor.lowBrakeForceSpeedLimit)
end
end
if spec.vThree == 5 or spec.vThree == nil then
spec.vThree = 1
else
spec.vThree = spec.vThree + 1
end
-- to make it easier read with dashbord-live
if sbshDebugOn then
print("BrRamp Taste losgelassen vThree: "..tostring(spec.vThree))
print("BrRamp Taste losgelassen lBFSL: "..self.spec_motorized.motor.lowBrakeForceSpeedLimit)
end
self:raiseDirtyFlags(spec.dirtyFlag)
if g_server ~= nil then
g_server:broadcastEvent(SyncClientServerEvent.new(self, spec.vOne, spec.vTwo, spec.vThree, spec.vFour, spec.vFive, spec.autoDiffs, spec.lastDirection, spec.isVarioTM, spec.isTMSpedal, spec.moveRpmL, spec.rpmDmax, spec.rpmrange, spec.CVTconfig, spec.forDBL_warnHeat, spec.forDBL_critHeat, spec.forDBL_warnDamage, spec.forDBL_critDamage, spec.CVTdamage, spec.HandgasPercent, spec.ClutchInputValue), nil, nil, self)
else
g_client:getServerConnection():sendEvent(SyncClientServerEvent.new(self, spec.vOne, spec.vTwo, spec.vThree, spec.vFour, spec.vFive, spec.autoDiffs, spec.lastDirection, spec.isVarioTM, spec.isTMSpedal, spec.moveRpmL, spec.rpmDmax, spec.rpmrange, spec.CVTconfig, spec.forDBL_warnHeat, spec.forDBL_critHeat, spec.forDBL_warnDamage, spec.forDBL_critDamage, spec.CVTdamage, spec.HandgasPercent, spec.ClutchInputValue))
end
if debug_for_DBL then
print("CVTa BR event: " .. spec.vThree)
print("CVTa BR 4_dbl: " .. spec.forDBL_brakeramp)
end
end --g_client
end -- BrakeRamps
function CVTaddon:AccRamps() -- BESCHLEUNIGUNGSRAMPEN - Motorbremswirkung wird kontinuirlich berechnet @update
local spec = self.spec_CVTaddon
if g_client ~= nil then
if sbshDebugOn then
print("AccRamp Taste gedrückt vTwo: "..tostring(spec.vTwo))
print("AccRamp Taste gedrückt acc: "..self.spec_motorized.motor.accelerationLimit)
end
if self.CVTaddon == nil then
return
end
if not CVTaddon.eventActiveV3 then
return
end
if (spec.vTwo == 1) then -- Ramp 1 +1
self.spec_motorized.motor.accelerationLimit = 0.35
self.spec_motorized.motor.lowBrakeForceScale = (math.abs(spec.calcBrakeForce-0.10))
if sbshDebugOn then
print("AccRamp 1 vTwo: "..tostring(spec.vTwo))
print("AccRamp 1 acc0.5: "..self.spec_motorized.motor.accelerationLimit)
end
end
if (spec.vTwo == 2) then -- Ramp 2 +1
self.spec_motorized.motor.accelerationLimit = 0.80
self.spec_motorized.motor.lowBrakeForceScale = (math.abs(spec.calcBrakeForce))
if sbshDebugOn then
print("AccRamp 2 vTwo: "..tostring(spec.vTwo))
print("AccRamp 2 acc1.0: "..self.spec_motorized.motor.accelerationLimit)
end
end
if (spec.vTwo == 3) then -- Ramp 3 +1
self.spec_motorized.motor.accelerationLimit = 1.20
self.spec_motorized.motor.lowBrakeForceScale = (math.abs(spec.calcBrakeForce+0.03))
if sbshDebugOn then
print("AccRamp 3 vTwo: "..tostring(spec.vTwo))
print("AccRamp 3 acc1.5: "..self.spec_motorized.motor.accelerationLimit)
end
end
if (spec.vTwo == 4) then -- Ramp 4 +1
self.spec_motorized.motor.accelerationLimit = 1.70 -- Standard
self.spec_motorized.motor.lowBrakeForceScale = (math.abs(spec.calcBrakeForce+0.08))
-- self.spec_motorized.motor.peakMotorTorque = self.spec_motorized.motor.peakMotorTorque * 0.5
if sbshDebugOn then
print("AccRamp 4 vTwo: "..tostring(spec.vTwo))
print("AccRamp 4 acc2.0: "..self.spec_motorized.motor.accelerationLimit)
end
end
if spec.vTwo == 4 or spec.vTwo == nil then
spec.vTwo = 1
else
spec.vTwo = spec.vTwo + 1
end
if sbshDebugOn then
print("AccRamp Taste losgelassen vTwo: "..tostring(spec.vTwo))
print("AccRamp Taste losgelassen acc: "..self.spec_motorized.motor.accelerationLimit)
end
-- DBL convert
if spec.vTwo == 1 then
spec.forDBL_accramp = tostring(4)
elseif spec.vTwo == 2 then
spec.forDBL_accramp = tostring(1)
elseif spec.vTwo == 3 then
spec.forDBL_accramp = tostring(2)
elseif spec.vTwo == 4 then
spec.forDBL_accramp = tostring(3)
end
self:raiseDirtyFlags(spec.dirtyFlag)
if g_server ~= nil then
g_server:broadcastEvent(SyncClientServerEvent.new(self, spec.vOne, spec.vTwo, spec.vThree, spec.vFour, spec.vFive, spec.autoDiffs, spec.lastDirection, spec.isVarioTM, spec.isTMSpedal, spec.moveRpmL, spec.rpmDmax, spec.rpmrange, spec.CVTconfig, spec.forDBL_warnHeat, spec.forDBL_critHeat, spec.forDBL_warnDamage, spec.forDBL_critDamage, spec.CVTdamage, spec.HandgasPercent, spec.ClutchInputValue), nil, nil, self)
else
g_client:getServerConnection():sendEvent(SyncClientServerEvent.new(self, spec.vOne, spec.vTwo, spec.vThree, spec.vFour, spec.vFive, spec.autoDiffs, spec.lastDirection, spec.isVarioTM, spec.isTMSpedal, spec.moveRpmL, spec.rpmDmax, spec.rpmrange, spec.CVTconfig, spec.forDBL_warnHeat, spec.forDBL_critHeat, spec.forDBL_warnDamage, spec.forDBL_critDamage, spec.CVTdamage, spec.HandgasPercent, spec.ClutchInputValue))
end
end -- g_client
end -- AccRamps
function CVTaddon:VarioRpmAxis(actionName, inputValue)
local spec = self.spec_CVTaddon
if g_client ~= nil then
if inputValue ~= nil then
spec.HandgasPercent = (math.floor(tonumber(inputValue) * 100)/100)
end
spec.forDBL_digitalhandgasstep = spec.vFive
-- print("CVTa HandgasPercent: " .. tostring(spec.HandgasPercent))
self:raiseDirtyFlags(spec.dirtyFlag)
-- if g_server ~= nil then
-- g_server:broadcastEvent(SyncClientServerEvent.new(self, spec.vOne, spec.vTwo, spec.vThree, spec.vFour, spec.vFive, spec.autoDiffs, spec.lastDirection, spec.isVarioTM, spec.isTMSpedal, spec.moveRpmL, spec.rpmDmax, spec.rpmrange, spec.CVTconfig, spec.forDBL_warnHeat, spec.forDBL_critHeat, spec.forDBL_warnDamage, spec.forDBL_critDamage, spec.CVTdamage, spec.HandgasPercent, spec.ClutchInputValue), nil, nil, self)
-- else
-- g_client:getServerConnection():sendEvent(SyncClientServerEvent.new(self, spec.vOne, spec.vTwo, spec.vThree, spec.vFour, spec.vFive, spec.autoDiffs, spec.lastDirection, spec.isVarioTM, spec.isTMSpedal, spec.moveRpmL, spec.rpmDmax, spec.rpmrange, spec.CVTconfig, spec.forDBL_warnHeat, spec.forDBL_critHeat, spec.forDBL_warnDamage, spec.forDBL_critDamage, spec.CVTdamage, spec.HandgasPercent, spec.ClutchInputValue))
-- end
end
end
function CVTaddon:VarioClutchAxis(actionName, inputValue)
local spec = self.spec_CVTaddon
if g_client ~= nil then
spec.ClutchInputValue = tonumber(inputValue)
spec.ClutchInputValue = (math.floor(spec.ClutchInputValue * 10)/10)
self:raiseDirtyFlags(spec.dirtyFlag)
if g_server ~= nil then
g_server:broadcastEvent(SyncClientServerEvent.new(self, spec.vOne, spec.vTwo, spec.vThree, spec.vFour, spec.vFive, spec.autoDiffs, spec.lastDirection, spec.isVarioTM, spec.isTMSpedal, spec.moveRpmL, spec.rpmDmax, spec.rpmrange, spec.CVTconfig, spec.forDBL_warnHeat, spec.forDBL_critHeat, spec.forDBL_warnDamage, spec.forDBL_critDamage, spec.CVTdamage, spec.HandgasPercent, spec.ClutchInputValue), nil, nil, self)
else
g_client:getServerConnection():sendEvent(SyncClientServerEvent.new(self, spec.vOne, spec.vTwo, spec.vThree, spec.vFour, spec.vFive, spec.autoDiffs, spec.lastDirection, spec.isVarioTM, spec.isTMSpedal, spec.moveRpmL, spec.rpmDmax, spec.rpmrange, spec.CVTconfig, spec.forDBL_warnHeat, spec.forDBL_critHeat, spec.forDBL_warnDamage, spec.forDBL_critDamage, spec.CVTdamage, spec.HandgasPercent, spec.ClutchInputValue))
end
end
end
function CVTaddon:VarioRpmPlus() -- Handgas hoch
local spec = self.spec_CVTaddon
if g_client ~= nil then
-- local spec = self.spec_CVTaddon
if sbshDebugOn then
print("VarioRpmPlus Taste gedrückt vFive: "..tostring(spec.vFive))
-- print("VarioRpmPlus : FwS/BwS/lBFS/cBF:")
end
if self.CVTaddon == nil then
return
end
if not CVTaddon.eventActiveV6 then
return
end
if spec.vFive < 10 then
spec.vFive = spec.vFive + 1
end
if spec.vFive >= 10 then
spec.vFive = 10
CVTaddon.eventActiveV6 = true
end
CVTaddon.eventActiveV7 = true
if sbshDebugOn then
print("VarioRpmPlus vFive: "..tostring(spec.vFive))
-- print("VarioRpmPlus : FwS/BwS/lBFS/cBF:")
end
if sbshDebugOn then
print("VarioRpmPlus Taste losgelassen vFive: "..tostring(spec.vFive))
-- print("VarioRpmPlus : FwS/BwS/lBFS/cBF:")
end
self:raiseDirtyFlags(spec.dirtyFlag)
if g_server ~= nil then
g_server:broadcastEvent(SyncClientServerEvent.new(self, spec.vOne, spec.vTwo, spec.vThree, spec.vFour, spec.vFive, spec.autoDiffs, spec.lastDirection, spec.isVarioTM, spec.isTMSpedal, spec.moveRpmL, spec.rpmDmax, spec.rpmrange, spec.CVTconfig, spec.forDBL_warnHeat, spec.forDBL_critHeat, spec.forDBL_warnDamage, spec.forDBL_critDamage, spec.CVTdamage, spec.HandgasPercent, spec.ClutchInputValue), nil, nil, self)
else
g_client:getServerConnection():sendEvent(SyncClientServerEvent.new(self, spec.vOne, spec.vTwo, spec.vThree, spec.vFour, spec.vFive, spec.autoDiffs, spec.lastDirection, spec.isVarioTM, spec.isTMSpedal, spec.moveRpmL, spec.rpmDmax, spec.rpmrange, spec.CVTconfig, spec.forDBL_warnHeat, spec.forDBL_critHeat, spec.forDBL_warnDamage, spec.forDBL_critDamage, spec.CVTdamage, spec.HandgasPercent, spec.ClutchInputValue))
end
end -- g_client
-- DBL convert
spec.forDBL_digitalhandgasstep = tostring(spec.vFive)
end
function CVTaddon:VarioRpmMinus() -- Handgas runter
local spec = self.spec_CVTaddon
if g_client ~= nil then
-- local spec = self.spec_CVTaddon
if sbshDebugOn then
print("VarioRpmMinus Taste gedrückt vFive: "..tostring(spec.vFive))
-- print("VarioRpmPlus : FwS/BwS/lBFS/cBF:")
end
if self.CVTaddon == nil then
return
end
if not CVTaddon.eventActiveV7 then
return
end
if spec.vFive > 0 then
spec.vFive = spec.vFive - 1
end
if spec.vFive <= 0 then
spec.vFive = 0
if self.spec_vca ~= nil then
self.spec_vca.handThrottle = 0
end
CVTaddon.eventActiveV7 = true