-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
clickable.lua
873 lines (647 loc) · 29.2 KB
/
clickable.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
dofile(LockOn_Options.script_path.."devices.lua")
dofile(LockOn_Options.script_path.."command_defs.lua")
dofile(LockOn_Options.script_path.."utils.lua")
dofile(LockOn_Options.script_path.."dump.lua")
local update_time_step = 0.02 --update will be called 50 times per second
make_default_activity(update_time_step)
sensor_data = get_base_data()
local dev = GetSelf()
local aircraft = get_aircraft_type()
--------------------------------------------------------------------
--Variable declaration
local mastermode = 0
local mastermodeF15 = 0
local radarScanAreaf15 = 1
local selecter_timer = 0
local radar_pos_az = 0
local planeradar_timer = 0
local bingo_timer = 0
local chutestate
local CLIC_MODE_AA_COUNTER
local CLIC_MODE_QUICK_COUNTER
--------------------------------------------------------------------
--local test = get_param_handle("BASE_SENSOR_RIGHT_THROTTLE_POS")
function post_initialize()
print_message_to_user("v1.0.2a-beta",10)
print_message_to_user(aircraft,10)
dispatch_action(nil,Keys.iCommandCockpitClickModeOnOff)
chutestate = 0
CLIC_MODE_AA_COUNTER = 0
CLIC_MODE_QUICK_COUNTER = 0
--dump("list_cockpit_params",list_cockpit_params())
local birth = LockOn_Options.init_conditions.birth_place
if birth=="GROUND_HOT" or birth=="AIR_HOT" then
elseif birth=="GROUND_COLD" then
end
end
function detect_rusian_air_to_air(aircraft)
if aircraft=="Su-33" or aircraft=="Su-27"or aircraft=="J-11A" or aircraft=="MiG-29A"or aircraft=="MiG-29G"or aircraft=="MiG-29S" then
return true
else
return false
end
end
function reset_mastermode(mastermode,AA)
local max_mastermode = 3
if AA == true then
max_mastermode = 7
end
if mastermode >max_mastermode then
return 2
elseif mastermode <=1 then
return 1
else
return mastermode
end
end
function reset_mastermodeF15(mastermodeF15)
local max_mastermodeF15 = 5
if mastermodeF15 >max_mastermodeF15 then
return 2
elseif mastermodeF15 <2 then
return 2
else
return mastermodeF15
end
end
function reset_radarScanAreaf15(radarScanAreaf15)
local max_radarScanAreaf15 = 1
if radarScanAreaf15 >max_radarScanAreaf15 then
return 1
elseif radarScanAreaf15 <0 then
return 0
else
return radarScanAreaf15
end
end
function SetCommand(command,value)
--print_message_to_user(value)
local AA = detect_rusian_air_to_air(aircraft)
if command == device_commands.CLIC_RBOOM and value == 1 then
dispatch_action(nil,Keys.iCommandPlaneAirRefuel)
end
if command == device_commands.CLIC_WHEELBRAKE then
dispatch_action(nil,Keys.iCommandPlaneWheelBrakeOn)
if value ~=1 then
dispatch_action(nil,Keys.iCommandPlaneWheelBrakeOff)
end
end
if command == device_commands.CLIC_GRID and value == 1 then
dispatch_action(nil,Keys.iCommandPlaneModeGrid)
end
if command == device_commands.CLIC_ASP and value >0 then
dispatch_action(0,Keys.iCommandPlaneHUDFilterOnOff,-1.0)
end
if command == device_commands.CLIC_ASP and value <0 then
dispatch_action(0,Keys.iCommandPlaneHUDFilterOnOff,1.0)
end
if command == device_commands.CLIC_TRIM_L then
dispatch_action(nil,Keys.iCommandPlaneTrimLeft)
if value ~=1 then
dispatch_action(nil,Keys.iCommandPlaneTrimStop)
end
end
if command == device_commands.CLIC_TRIM_R then
dispatch_action(nil,Keys.iCommandPlaneTrimRight)
if value ~=1 then
dispatch_action(nil,Keys.iCommandPlaneTrimStop)
end
end
if command == device_commands.CLIC_TRIM_U then
dispatch_action(nil,Keys.iCommandPlaneTrimDown)
if value ~=1 then
dispatch_action(nil,Keys.iCommandPlaneTrimStop)
end
end
if command == device_commands.CLIC_TRIM_D then
dispatch_action(nil,Keys.iCommandPlaneTrimUp)
if value ~=1 then
dispatch_action(nil,Keys.iCommandPlaneTrimStop)
end
end
if command == device_commands.CLIC_TGT_L then
dispatch_action(nil,Keys.iCommandPlaneRadarLeft)
if value ~=1 then
dispatch_action(nil,Keys.iCommandPlaneRadarStop)
end
end
if command == device_commands.CLIC_TGT_R then
dispatch_action(nil,Keys.iCommandPlaneRadarRight)
if value ~=1 then
dispatch_action(nil,Keys.iCommandPlaneRadarStop)
end
end
if command == device_commands.CLIC_TGT_U then
dispatch_action(nil,Keys.iCommandPlaneRadarUp)
if value ~=1 then
dispatch_action(nil,Keys.iCommandPlaneRadarStop)
end
end
if command == device_commands.CLIC_TGT_D then
dispatch_action(nil,Keys.iCommandPlaneRadarDown)
if value ~=1 then
dispatch_action(nil,Keys.iCommandPlaneRadarStop)
end
end
if command == device_commands.CLIC_NAVMODES and value ~=0 then
dispatch_action(nil,Keys.iCommandPlaneModeNAV)
end
if command == device_commands.CLIC_STATION and value == 1 then
dispatch_action(nil,Keys.iCommandPlaneChangeWeapon)
end
if command == device_commands.CLIC_LOCK and value == 1 then
dispatch_action(nil,Keys.iCommandPlaneChangeLock)
end
if command == device_commands.CLIC_LOCK_REL and value == 1 then
dispatch_action(nil,Keys.iCommandSensorReset)
end
if command == device_commands.CLIC_CTM_ONCE and value == 1 then
dispatch_action(nil,Keys.iCommandPlaneDropSnarOnce)
end
if command == device_commands.CLIC_AIRBRAKE and value == 1 then
dispatch_action(nil,Keys.iCommandPlaneAirBrake)
end
if command == device_commands.CLIC_WAYPOINT and value >0 then
dispatch_action(nil,Keys.iCommandPlaneChangeTarget)
elseif command == device_commands.CLIC_WAYPOINT and value <0 then
dispatch_action(nil,Keys.iCommandPlaneUFC_STEER_DOWN)
end
if command == device_commands.CLIC_MODE and value >0 then
mastermode = mastermode +1
elseif command == device_commands.CLIC_MODE and value <0 then
mastermode = mastermode -1
end
mastermode = reset_mastermode(mastermode,AA)
if command == device_commands.CLIC_MODE_AA and value ==1 then
CLIC_MODE_AA_COUNTER = CLIC_MODE_AA_COUNTER +1
if mastermode == 8 then
dispatch_action(nil,Keys.iCommandPlaneModeGrid)
end
mastermode = 0
if CLIC_MODE_AA_COUNTER == 1 then
dispatch_action(nil,Keys.iCommandPlaneModeBVR)
end
if CLIC_MODE_AA_COUNTER == 2 then
dispatch_action(nil,Keys.iCommandPlaneModeVS)
CLIC_MODE_AA_COUNTER = 0
end
end
if command == device_commands.CLIC_MODE_QUICK and value ==1 then
CLIC_MODE_QUICK_COUNTER = CLIC_MODE_QUICK_COUNTER +1
if mastermode == 6 then
dispatch_action(nil,Keys.iCommandPlaneModeGrid)
end
mastermode = 0
if CLIC_MODE_QUICK_COUNTER == 1 then
dispatch_action(nil,Keys.iCommandPlaneModeFI0)
end
if CLIC_MODE_QUICK_COUNTER == 2 then
dispatch_action(nil,Keys.iCommandPlaneModeGround)
CLIC_MODE_QUICK_COUNTER = 0
end
end
if command == device_commands.CLIC_MODE then
if AA == true then
if mastermode == 2 then
dispatch_action(nil,Keys.iCommandPlaneModeBVR)
elseif mastermode == 3 then
dispatch_action(nil,Keys.iCommandPlaneModeVS)
elseif mastermode == 4 then
dispatch_action(nil,Keys.iCommandPlaneModeBore)
elseif mastermode == 5 then
dispatch_action(nil,Keys.iCommandPlaneModeHelmet)
elseif mastermode == 6 then
dispatch_action(nil,Keys.iCommandPlaneModeFI0)
elseif mastermode == 7 then
dispatch_action(nil,Keys.iCommandPlaneModeGround)
end
else
if mastermode == 2 then
dispatch_action(nil,Keys.iCommandPlaneModeFI0)
elseif mastermode == 3 then
dispatch_action(nil,Keys.iCommandPlaneModeGround)
end
if command == device_commands.CLIC_LASER and value ==1 then
dispatch_action(nil, Keys.iCommandPlaneLaserRangerOnOff)
end
if command == device_commands.CLIC_TV_NIGHT and value == 1 then
dispatch_action(nil, Keys.iCommandPlaneNightTVOnOff)
end
if command == device_commands.CLIC_ZOOM and value >0 then
dispatch_action(nil,Keys.iCommandPlaneZoomIn)
elseif command == device_commands.CLIC_ZOOM and value <0 then
dispatch_action(nil,Keys.iCommandPlaneZoomOut)
end
end
end
--One-button parachute control
if command == device_commands.CLIC_CHUTE and value == 1 then
dispatch_action(nil,Keys.iCommandPlaneParachute)
end
--Two-button parachute control
if aircraft=="Su-27"or aircraft=="J-11A" or aircraft=="MiG-29A"or aircraft=="MiG-29G"or aircraft=="MiG-29S" or aircraft=="Su-25T" then
if command == device_commands.CLIC_CHUTE_DEP then
if value == 1 then
if chutestate == 0 then
dispatch_action(true, Keys.iCommandPlaneParachute)
chutestate = 1
end
end
elseif command == device_commands.CLIC_CHUTE_REL then
if value == 1 then
if chutestate == 1 then
dispatch_action(true, Keys.iCommandPlaneParachute)
chutestate = -1
end
end
end
end
if command == device_commands.CLIC_RADAR_FREQ and value == 1 then
dispatch_action(nil,Keys.iCommandPlaneChangeRadarPRF)
end
if command == device_commands.CLIC_FLAPS_MULTI and value == 1 then
dispatch_action(nil,Keys.iCommandPlaneFlaps)
end
if command == device_commands.CLIC_FLAPS_UP then
dispatch_action(nil,Keys.iCommandPlaneFlapsOff)
end
if command == device_commands.CLIC_FLAPS_DOWN or command == device_commands.CLIC_FLAPS_LAND then
dispatch_action(nil,Keys.iCommandPlaneFlapsOn)
end
if command == device_commands.CLIC_LANDING_LIGHTS and value ==1 then
dispatch_action(nil,Keys.iCommandPlaneHeadLightOnOff)
end
if command == device_commands.CLIC_ASC_DC and value ==1 then
dispatch_action(nil,Keys.iCommandPlaneCobra)
end
if command == device_commands.CLIC_FUEL_DUMP_ON then
dispatch_action(nil,Keys.iCommandPlaneFuelOn)
end
if command == device_commands.CLIC_FUEL_DUMP_OFF then
dispatch_action(nil,Keys.iCommandPlaneFuelOff)
end
if command == device_commands.CLIC_AUTO_GCA and value == 1 then
dispatch_action(nil,Keys.iCommandPlaneSAUHRadio)
end
if command == device_commands.CLIC_AUTO_PATH and value == 1 then
dispatch_action(nil,Keys.iCommandPlaneRouteAutopilot)
end
if command == device_commands.CLIC_AUTO_REAP and value == 1 then
dispatch_action(nil,Keys.iCommandPlaneStabHrad)
end
if command == device_commands.CLIC_AUTO_DAMPER then
dispatch_action(nil,Keys.iCommandPlaneStabHbarBank)
end
if command == device_commands.CLIC_AUTO_STOP then
dispatch_action(nil,Keys.iCommandPlaneStabCancel)
end
if command == device_commands.CLIC_AUTO_BARO and value ==1 then
dispatch_action(nil,Keys.iCommandPlaneStabHbarBank)
end
if command == device_commands.CLIC_AUTO_RADAR and value ==1 then
dispatch_action(nil,Keys.iCommandPlaneStabHrad)
end
if command == device_commands.CLIC_AUTO_LEVEL and value ==1 then
dispatch_action(nil,Keys.iCommandPlaneStabHorizon)
end
if command == device_commands.CLIC_AUTO_ROUTE and value ==1 then
dispatch_action(nil,Keys.iCommandPlaneRouteAutopilot)
end
if command == device_commands.CLIC_AUTO_ALT and value ==1 then
dispatch_action(nil,Keys.iCommandPlaneStabTangBank)
end
if command == device_commands.CLIC_HUD_REPEATER and value ==1 then
dispatch_action(nil,Keys.iCommandPlaneRightMFD_OSB1)
end
if command == device_commands.CLIC_POWER and value ==1 then
dispatch_action(nil,Keys.iCommandPowerOnOff)
end
if command == device_commands.CLIC_ENG_L_START and value ==1 then
dispatch_action(nil,Keys.iCommandLeftEngineStart)
end
if command == device_commands.CLIC_ENG_R_START and value ==1 then
dispatch_action(nil,Keys.iCommandRightEngineStart)
end
if command == device_commands.CLIC_ENG_L_STOP then
dispatch_action(nil,Keys.iCommandLeftEngineStop)
end
if command == device_commands.CLIC_ENG_R_STOP then
dispatch_action(nil,Keys.iCommandRightEngineStop)
end
if command == device_commands.CLIC_CTM and value ==1 then
dispatch_action(nil,Keys.iCommandPlaneDropSnar)
end
if command == device_commands.CLIC_CTM_CHAFF and value ==1 then
dispatch_action(nil,Keys.iCommandPlaneDropChaffOnce)
end
if command == device_commands.CLIC_CTM_FLARE and value ==1 then
dispatch_action(nil,Keys.iCommandPlaneDropFlareOnce)
end
if command == device_commands.CLIC_JAM_IR and value ==1 then
dispatch_action(nil,Keys.iCommandActiveIRJamming)
end
if command == device_commands.CLIC_JAM and value ==1 then
dispatch_action(nil,Keys.iCommandActiveJamming)
end
if command == device_commands.CLIC_HUD_FILTER and value ==1 then
dispatch_action(nil,Keys.iCommandPlaneHUDFilterOnOff)
end
if command == device_commands.CLIC_GEAR and value ==1 then
dispatch_action(nil,Keys.iCommandPlaneGear)
end
if command == device_commands.CLIC_CANOPY and value ==1 then
dispatch_action(nil,Keys.iCommandPlaneFonar)
end
if command == device_commands.CLIC_NAVLIGHTS and value ==1 then
dispatch_action(nil,Keys.iCommandPlaneLightsOnOff)
end
if command == device_commands.CLIC_COCKPITLIGHT and value ==1 then
dispatch_action(nil,Keys.iCommandPlaneCockpitIllumination)
end
if command == device_commands.CLIC_JETTINSON_TANK and value ==1 then
dispatch_action(nil,Keys.iCommandPlaneJettisonFuelTanks)
end
if command == device_commands.CLIC_JETTINSON and value ==1 then
dispatch_action(nil,Keys.iCommandPlaneJettisonWeapons)
end
if command == device_commands.CLIC_JETTINSON_EMER and value ==1 then
dispatch_action(nil,Keys.iCommandPlaneJettisonWeapons)
dispatch_action(nil,Keys.iCommandPlaneJettisonWeapons)
dispatch_action(nil,Keys.iCommandPlaneJettisonWeapons)
dispatch_action(nil,Keys.iCommandPlaneJettisonWeapons)
dispatch_action(nil,Keys.iCommandPlaneJettisonWeapons)
dispatch_action(nil,Keys.iCommandPlaneJettisonWeapons)
dispatch_action(nil,Keys.iCommandPlaneJettisonWeapons)
dispatch_action(nil,Keys.iCommandPlaneJettisonWeapons)
dispatch_action(nil,Keys.iCommandPlaneJettisonWeapons)
dispatch_action(nil,Keys.iCommandPlaneJettisonWeapons)
end
if command == device_commands.CLIC_RADAR_ON_OFF and value ==1 then
dispatch_action(nil,Keys.iCommandPlaneRadarOnOff)
end
if command == device_commands.CLIC_TV and value ==1 then
dispatch_action(nil,Keys.iCommandPlaneEOSOnOff)
end
if command == device_commands.CLIC_SCAN_L then
dispatch_action(nil,Keys.iCommandSelecterLeft)
if value ~=1 then
dispatch_action(nil,Keys.iCommandSelecterStop)
end
end
if command == device_commands.CLIC_SCAN_R then
dispatch_action(nil,Keys.iCommandSelecterRight)
if value ~=1 then
dispatch_action(nil,Keys.iCommandSelecterStop)
end
end
if command == device_commands.CLIC_SCAN_EL then
selecter_timer = 0.025
if command == device_commands.CLIC_SCAN_EL and value ==-1 then
dispatch_action(nil,Keys.iCommandSelecterDown)
--print_message_to_user("iCommandSelecterDown")
end
if command == device_commands.CLIC_SCAN_EL and value ==1 then
dispatch_action(nil,Keys.iCommandSelecterUp)
--print_message_to_user("iCommandSelecterUp")
end
end
if command == device_commands.CLIC_HUD_COLOR and value == 1 then
dispatch_action(nil,Keys.iCommandBrightnessILS)
end
if command == device_commands.CLIC_HUD_BRT and value >0 then
dispatch_action(nil,Keys.iCommandHUDBrightnessUp)
dispatch_action(nil,Keys.iCommandHUDBrightnessUp)
dispatch_action(nil,Keys.iCommandHUDBrightnessUp)
dispatch_action(nil,Keys.iCommandHUDBrightnessUp)
elseif command == device_commands.CLIC_HUD_BRT and value <0 then
dispatch_action(nil,Keys.iCommandHUDBrightnessDown)
dispatch_action(nil,Keys.iCommandHUDBrightnessDown)
dispatch_action(nil,Keys.iCommandHUDBrightnessDown)
dispatch_action(nil,Keys.iCommandHUDBrightnessDown)
end
if command == device_commands.CLIC_MIRROR and value == 1 then
dispatch_action(nil,Keys.iCommandToggleMirrors)
end
if command == device_commands.CLIC_ENG_INLET and value == 1 then
dispatch_action(nil,Keys.iCommandPlane_HOTAS_ChinaHatForward)
end
if command == device_commands.CLIC_NOSE_WHEEL and value == 1 then
dispatch_action(nil,Keys.iCommandPlane_HOTAS_NoseWheelSteeringButton)
end
if command == device_commands.CLIC_EJECT and value == 1 then
dispatch_action(nil,Keys.iCommandPlaneEject)
end
if command == device_commands.CLIC_RWR_MODE and value == 1 then
dispatch_action(nil,Keys.iCommandChangeRWRMode)
end
if command == device_commands.CLIC_RWR_SOUND and value >0 then
dispatch_action(nil,Keys.iCommandPlaneThreatWarnSoundVolumeUp)
dispatch_action(nil,Keys.iCommandPlaneThreatWarnSoundVolumeUp)
elseif command == device_commands.CLIC_RWR_SOUND and value <0 then
dispatch_action(nil,Keys.iCommandPlaneThreatWarnSoundVolumeDown)
dispatch_action(nil,Keys.iCommandPlaneThreatWarnSoundVolumeDown)
end
if command == device_commands.CLIC_WARNING_RST and value == 1 then
dispatch_action(nil,Keys.iCommandPlaneResetMasterWarning)
end
if command == device_commands.CLIC_DSP_ZOOMIN and value == 1 then
dispatch_action(nil,Keys.iCommandPlaneZoomIn)
end
if command == device_commands.CLIC_DSP_ZOOMOUT and value == 1 then
dispatch_action(nil,Keys.iCommandPlaneZoomOut)
end
if command == device_commands.CLIC_CLOCK_F and value == 1 then
dispatch_action(nil,Keys.iCommandFlightClockReset)
end
if command == device_commands.CLIC_CLOCK_E and value == 1 then
dispatch_action(nil,Keys.iCommandClockElapsedTimeReset)
end
if command == device_commands.CLIC_ALTIMETER and value >0 then
dispatch_action(nil,Keys.iCommandAltimeterPressureIncrease)
dispatch_action(nil,Keys.iCommandAltimeterPressureIncrease)
dispatch_action(nil,Keys.iCommandAltimeterPressureIncrease)
elseif command == device_commands.CLIC_ALTIMETER and value <0 then
dispatch_action(nil,Keys.iCommandAltimeterPressureDecrease)
dispatch_action(nil,Keys.iCommandAltimeterPressureDecrease)
dispatch_action(nil,Keys.iCommandAltimeterPressureDecrease)
end
--Brake control specific to Flankers and derivatives
if aircraft=="Su-33" or aircraft=="Su-27"or aircraft=="J-11A" then
if command == device_commands.CLIC_EMER_BRAKE and value == 1 then
dispatch_action(nil,Keys.iCommandPlaneWheelParkingBrake)
end
end
--Su-33 Specifics
if aircraft=="Su-33" then
if command == device_commands.CLIC_AUTOTHRUST and value == 1 then
dispatch_action(nil,Keys.iCommandPlaneAUTOnOff)
end
if command == device_commands.CLIC_AUTOTHRUST_I and value == 1 then
dispatch_action(0,Keys.iCommandPlaneAUTIncrease,1.0)
elseif value == 0 then
dispatch_action(0,Keys.iCommandPlaneAUTIncrease,0.0)
end
if command == device_commands.CLIC_AUTOTHRUST_D and value == 1 then
dispatch_action(0,Keys.iCommandPlaneAUTIncrease,-1.0)
elseif value == 0 then
dispatch_action(0,Keys.iCommandPlaneAUTIncrease,0.0)
end
if command == device_commands.CLIC_ASC_REFUEL and value == 1 then
dispatch_action(nil,Keys.iCommandPlane_ADF_Mode_change)
end
if command == device_commands.CLIC_AFTERURN_S and value == 1 then
dispatch_action(nil,Keys.iCommandPlane_P_51_WarEmergencyPower)
end
if command == device_commands.CLIC_RLIGHTS and value == 1 then
dispatch_action(nil,Keys.iCommandPlane_ADF_Test)
end
if command == device_commands.CLIC_TAILHOOK and value == 1 then
dispatch_action(nil,Keys.iCommandPlaneHook)
end
if command == device_commands.CLIC_WINGSF and value == 1 then
dispatch_action(nil,Keys.iCommandPlanePackWing)
end
end
if command == device_commands.CLIC_RIPPLE_INT and value >0 then
dispatch_action(nil,Keys.iCommandChangeRippleInterval)
elseif command == device_commands.CLIC_RIPPLE_INT and value <0 then
dispatch_action(nil,Keys.iCommandChangeRippleIntervalDown)
end
if command == device_commands.CLIC_RIPPLE_QT and value == 1 then
dispatch_action(nil,Keys.iCommandChangeRippleQuantity)
end
if command == device_commands.CLIC_RIPPLE_QTA10 then
dispatch_action(nil,Keys.iCommandChangeRippleQuantity)
end
if command == device_commands.CLIC_CUTBURST and value == 1 then
dispatch_action(nil,Keys.iCommandChangeGunRateOfFire)
end
if command == device_commands.CLIC_PRS_SGL then
dispatch_action(nil,Keys.iCommandChangeReleaseMode)
end
if command == device_commands.CLIC_RADAR_EL then
selecter_timer = 0.3
if value ==1 then
dispatch_action(nil,Keys.iCommandSelecterUp)
elseif value ==0 then
dispatch_action(nil,Keys.iCommandSelecterDown)
end
end
if command == device_commands.CLIC_TARGET_UD then
planeradar_timer = 0.15
if value ==1 then
dispatch_action(nil,Keys.iCommandPlaneRadarUp)
elseif value ==0 then
dispatch_action(nil,Keys.iCommandPlaneRadarDown)
end
end
if command == device_commands.CLIC_TARGET_LR then
planeradar_timer = 0.20
if value ==1 then
dispatch_action(nil,Keys.iCommandPlaneRadarLeft)
elseif value ==0 then
dispatch_action(nil,Keys.iCommandPlaneRadarRight)
end
end
if command == device_commands.CLIC_RIPPLE_INT and value >0 then
dispatch_action(nil,Keys.iCommandChangeRippleInterval)
elseif command == device_commands.CLIC_RIPPLE_INT and value <0 then
dispatch_action(nil,Keys.iCommandChangeRippleIntervalDown)
end
if command == device_commands.CLIC_EMERGENCY_BRAKES_ON and value == 1 then
dispatch_action(nil,Keys.iCommandPlaneWheelBrakeOn)
print_message_to_user("Emergency Brakes\nEngaged")
end
if command == device_commands.CLIC_EMERGENCY_BRAKES_OFF and value == 1 then
dispatch_action(nil,Keys.iCommandPlaneWheelBrakeOff)
print_message_to_user("Emergency Brakes\nDisengaged")
end
--F-15C Specifics
if aircraft=="F-15C" then
if command == device_commands.CLIC_FIRE and value == 1 then
dispatch_action(nil,Keys.iCommandPlanePickleOn)
else
dispatch_action(nil,Keys.iCommandPlanePickleOff)
end
if command == device_commands.CLIC_LANDING_LIGHTS_F15 then
dispatch_action(nil,Keys.iCommandPlaneHeadLightOnOff)
end
if command == device_commands.CLIC_BINGO then
bingo_timer = 0.25
if value ==-1 then
dispatch_action(0,Keys.iCommandPlaneFSQuantityIndicatorSelectorINT,-1)
elseif value ==1 then
dispatch_action(0,Keys.iCommandPlaneFSQuantityIndicatorSelectorINT,1)
end
end
end
-- Master Combat Mode Controls
-- To be reworked to implement the Navigation mod which has two sub mods, which causes problems.
if command == device_commands.CLIC_MODE_F15 and value >0 then
mastermodeF15 = mastermodeF15 +1
elseif command == device_commands.CLIC_MODE_F15 and value <0 then
mastermodeF15 = mastermodeF15 -1
end
if command == device_commands.CLIC_MODE_F15 then
if mastermodeF15 == 2 then
dispatch_action(nil,Keys.iCommandPlaneModeBVR)
elseif mastermodeF15 == 3 then
dispatch_action(nil,Keys.iCommandPlaneModeVS)
elseif mastermodeF15 == 4 then
dispatch_action(nil,Keys.iCommandPlaneModeBore)
elseif mastermodeF15 == 5 then
dispatch_action(nil,Keys.iCommandPlaneModeFI0)
end
mastermodeF15 = reset_mastermodeF15(mastermodeF15)
end
--Radar Controls
if command == device_commands.CLIC_ZOOM_F15 and value >0 then
dispatch_action(nil,Keys.iCommandPlaneZoomIn)
elseif command == device_commands.CLIC_ZOOM_F15 and value <0 then
dispatch_action(nil,Keys.iCommandPlaneZoomOut)
end
if command == device_commands.CLIC_RADAR_FREQ_F15 then
dispatch_action(nil,Keys.iCommandPlaneChangeRadarPRF)
end
if command == device_commands.CLIC_RADAR_ON_OFF_F15 then
dispatch_action(nil,Keys.iCommandPlaneRadarOnOff)
end
if command == device_commands.CLIC_RADAR_AZ and value >0 then
radarScanAreaf15 = radarScanAreaf15 +1
elseif command == device_commands.CLIC_RADAR_AZ and value <0 then
radarScanAreaf15 = radarScanAreaf15 -1
end
if command == device_commands.CLIC_RADAR_AZ then
if radarScanAreaf15 == 1 then
dispatch_action(nil,Keys.iCommandIncreaseRadarScanArea)
elseif radarScanAreaf15 == 0 then
dispatch_action(nil,Keys.iCommandDecreaseRadarScanArea)
end
end
radarScanAreaf15 = reset_radarScanAreaf15(radarScanAreaf15)
end
function update()
--print_message_to_user(mastermodeF15)
if selecter_timer > 0 then
selecter_timer = selecter_timer - update_time_step
if selecter_timer <= 0 then
selecter_timer = 0
dispatch_action(nil,Keys.iCommandSelecterStop)
end
end
if planeradar_timer > 0 then
planeradar_timer = planeradar_timer - update_time_step
if planeradar_timer <= 0 then
planeradar_timer = 0
dispatch_action(nil,Keys.iCommandPlaneRadarStop)
end
end
if bingo_timer > 0 then
bingo_timer = bingo_timer - update_time_step
if bingo_timer <= 0 then
bingo_timer = 0
dispatch_action(0,Keys.iCommandPlaneFSQuantityIndicatorSelectorINT,0)
end
end
end
need_to_be_closed = false -- close lua state after initialization