3 # ==================================== timer stuff ===========================================
5 # set the update period
9 # set the timer for the selected function
11 registerTimer = func {
13 settimer(arg[0], UPDATE_PERIOD);
17 # =============================== end timer stuff ===========================================
19 # =============================== Boost Controller stuff======================================
21 BOOST_CONTROL_AUTHORITY = 0.99; # How much can it move the throttle?
22 #BOOST_CONTROL_RANGE = 1; When does it start to engage? (psig)
23 BOOST_CONTROL_LIMIT_RATED = 11.9; # Maximum MP (psig)
24 BOOST_CONTROL_LIMIT_COMBAT = 18; # Combat limit (5 mins)
26 boost_control = props.globals.getNode("/controls/engines/engine/boost-control", 1);
27 boost_pressure = props.globals.getNode("/engines/engine/boost-gauge-inhg", 1);
28 boost_pressure_psi = props.globals.getNode("/engines/engine/boost-gauge-psi", 1);
29 boost_control_damp = props.globals.getNode("/controls/engines/engine/boost-control-damp", 1);
30 boost_control_range = props.globals.getNode("/controls/engines/engine/boost-control-range", 1);
31 boost_control_cutout = props.globals.getNode("/controls/engines/engine/boost-control-cutout", 1);
32 mp_inhg = props.globals.getNode("/engines/engine/mp-inhg", 1);
34 boost_control.setDoubleValue(1);
35 boost_pressure.setDoubleValue(0);
36 boost_pressure_psi.setDoubleValue(0);
37 boost_control_damp.setDoubleValue(0.015);
38 boost_control_range.setDoubleValue(0.5);
39 boost_control_cutout.setBoolValue(0);
40 mp_inhg.setDoubleValue(0);
46 b = getprop("controls/engines/engine/boost");
54 setprop("controls/engines/engine/boost",b);
57 } # end function toggleBoost
60 var c = boost_control_cutout.getValue();
63 boost_control_cutout.setBoolValue(c);
67 } # end function toggleCutout
69 updateBoostControl = func {
70 var n = boost_control_damp.getValue();
71 var BOOST_CONTROL_RANGE = boost_control_range.getValue();
72 var mp = (mp_inhg.getValue() * 0.491154077497) - 14.6959487755 ;
73 var cutout = boost_control_cutout.getValue();
77 val = (mp - BOOST_CONTROL_LIMIT_RATED) / BOOST_CONTROL_RANGE;
79 val = (mp - BOOST_CONTROL_LIMIT_COMBAT) / BOOST_CONTROL_RANGE;
85 val = 0; # Can't increase throttle
86 } elsif (val < -BOOST_CONTROL_AUTHORITY) {
87 val = -BOOST_CONTROL_AUTHORITY # limit by authority
92 damp = (val * n) + (damp * (1 - n)); # apply low pass filter
94 # print(sprintf("mp=%0.5f, in=%0.5f, raw=%0.5f, out=%0.5f", mp, in, val, damp));
95 boost_pressure_psi.setDoubleValue(mp);
96 boost_control.setDoubleValue(damp);
97 boost_control_cutout.setBoolValue(cutout);
98 settimer(updateBoostControl, 0.1);
101 updateBoostControl();
104 # ======================================= end Boost Controller f ============================
108 # =============================== set the aircraft type =====================================
112 type = getprop("sim/aircraft");
114 if (type == "spitfireIIa") {spitfireIIa = 1;}
116 print ("type: " , type );
117 # ============================= Coffman starter stuff =======================================
120 nowN = props.globals.getNode("/sim/time/elapsed-sec", 1);
121 starterN = props.globals.getNode("controls/engines/engine/starter", 1);
122 primerN = props.globals.getNode("controls/engines/engine/primer", 1);
123 cartridgeN = props.globals.getNode("controls/engines/engine/coffman-starter/index");
126 Start = 0; # stopCof needs this, too
132 # i = getprop("controls/engines/engine/coffman-starter/index");
133 i = cartridgeN.getValue();
138 setprop("controls/engines/engine/coffman-starter/index",i);
139 setprop("controls/engines/engine/coffman-starter/index-pull-norm",1)
141 setprop("controls/engines/engine/coffman-starter/index-pull-norm",0)
152 LastStartTime = nowN.getValue();
153 if (!starterN.getValue()) { # not started yet: do it now
154 setprop("controls/engines/engine/coffman-starter/starter-push-norm", 1);
156 ready = !hurricane.spitfireIIa; # seafires are always ready
158 if (!ready) { # must be a spitfire
159 LastCartridge = cartridgeN.getValue();
160 j = "controls/engines/engine/coffman-starter/cartridge[" ~ LastCartridge ~ "]";
161 if (ready = getprop(j)) {
163 # print("max run: " , max_run);
164 settimer(func { # nameless out-of-gas watcher
165 starterN.setValue(0);
167 print ("starter stopping, out of gas!");
172 primerMixture(primerN.getValue());
173 starterN.setValue(1);
174 # print ("starter running!", primerN.getValue());
178 settimer(stopCof, 0.2);
186 if (!Start and starterN.getValue()) {
187 if (nowN.getValue() - LastStartTime < min_run) {
188 settimer(stopCof, 0.2); # too soon; let's try again later
189 # print ("too soon! min run: " , min_run);
193 starterN.setValue(0);
194 setprop("controls/engines/engine/coffman-starter/starter-push-norm", 0);
195 # print ("starter stopping!");
200 # ============================ end Coffman starter stuff =====================================
202 # ================================= priming pump stuff =======================================
209 pump = getprop("controls/engines/engine/primer") + 1;
210 setprop("controls/engines/engine/primer", pump);
211 setprop("controls/engines/engine/primer-pump",1);
215 setprop("controls/engines/engine/primer-pump",0);
220 primerMixture = func{
225 if(primer >3 and primer <7) {
233 # ================================== end priming pump stuff =================================
235 # ================================= magneto stuff ===========================================
237 setMagnetos = func{ # set the magneto value according to the switch positions
239 right = getprop("controls/engines/engine/mag-switch-right");
240 left = getprop("controls/engines/engine/mag-switch-left");
241 if (left and right){ # both
242 setprop("controls/engines/engine/magnetos",3);
244 elsif (left and !right) { # left
245 setprop("controls/engines/engine/magnetos",1)
247 elsif (!left and right) { # right
248 setprop("controls/engines/engine/magnetos",2)
251 setprop("controls/engines/engine/magnetos",0); # none
256 setleftMagswitch = func{
259 setprop("controls/engines/engine/mag-switch-left",left);
260 hurricane.setMagnetos();
265 setrightMagswitch = func{
268 setprop("controls/engines/engine/mag-switch-right",right);
269 hurricane.setMagnetos();
274 toggleleftMagswitch = func{
276 left = getprop("controls/engines/engine/mag-switch-left");
278 setprop("controls/engines/engine/mag-switch-left",left);
279 hurricane.setMagnetos();
283 togglerightMagswitch = func{
285 right = getprop("controls/engines/engine/mag-switch-right");
287 setprop("controls/engines/engine/mag-switch-right",right);
288 hurricane.setMagnetos();
292 # =============================== end magneto stuff =========================================
294 # ====================================== door and canopy stuff ==============================
296 openDoor = func{ # open the door if canopy is open
299 canopyopen = getprop("gear/canopy/position-norm");
301 setprop("controls/flight/door-position-norm",dooropen)
306 toggleDoor = func{ # toggle the door if canopy is open
308 dooropen = getprop("controls/flight/door-position-norm");
309 canopyopen = getprop("gear/canopy/position-norm");
311 dooropen = !dooropen;
312 setprop("controls/flight/door-position-norm",dooropen);
317 openCanopy = func{ # open the canopy if door is closed
320 dooropen = getprop("controls/flight/door-position-norm");
322 setprop("controls/flight/canopy-slide",canopyopen)
327 # ==================================== end door and canopy ===================================
329 # ======================================== Cutoff ============================================
334 mixturelever = getprop("controls/engines/engine/mixture-lever");
337 setprop("controls/engines/engine/cutoff-pull-norm",1);
338 setprop("controls/engines/engine/cutoff",0);
339 #setprop("controls/engines/engine/mixture",0);
340 if (getprop("engines/engine/rpm") < 100) {setprop("engines/engine/running",0)}
342 setprop("controls/engines/engine/cutoff-pull-norm",0);
343 setprop("controls/engines/engine/cutoff",1);
344 #setprop("controls/engines/engine/mixture",mixturelever)
349 # =================================== end Cutoff ============================================
353 # ======================================= fuel tank stuff ===================================
357 setTankContents=func{
359 tank=getprop("controls/switches/fuel-gauge-sel");
360 contents=getprop("consumables/fuel/tank[" ~ tank ~ "]/level-gal_us");
361 setprop("instrumentation/fuel/contents-gal_us",contents);
362 # print("contents: " , contents, " tank: " , tank);
363 registerTimer(setTankContents);
367 registerTimer(setTankContents);
373 cock=getprop("controls/engines/engine/fuel-cock/lever");
377 setprop("controls/engines/engine/fuel-cock/lever",cock);
385 cock=getprop("controls/engines/engine/fuel-cock/lever");
389 setprop("controls/engines/engine/fuel-cock/lever",cock);
400 lever=getprop("controls/engines/engine/fuel-cock/lever");
403 setprop("consumables/fuel/tank[0]/selected",0);
404 setprop("consumables/fuel/tank[1]/selected",0);
405 setprop("consumables/fuel/tank[2]/selected",0);
408 setprop("consumables/fuel/tank[0]/selected",1);
409 setprop("consumables/fuel/tank[1]/selected",1);
410 setprop("consumables/fuel/tank[2]/selected",0);
413 setprop("consumables/fuel/tank[0]/selected",0);
414 setprop("consumables/fuel/tank[1]/selected",0);
415 setprop("consumables/fuel/tank[2]/selected",1);
420 # ========================== end fuel stuff ======================================
423 # =========================== hydraulic stuff =========================================
425 #controls.gearDown = func(x) { if (x) { hydraulicLever(-1, -x) } }
426 #controls.flapsDown = func(x) { if (x) { hydraulicLever(1, -x) } }
428 #hydraulicLever = func{ #sets the lever up-down, right-left or neutral
434 # print("input: ", right, " ", up);
436 # lever[0]= getprop("controls/hydraulic/lever[0]"); #right/left
437 # lever[1]= getprop("controls/hydraulic/lever[1]"); #up/down
439 # print ("lever in: ", lever[0],lever[1]);
441 # if ( lever[0] == 0 or lever[0] == right) { #
442 # if (up == 1 and lever[1] < 1){
443 # lever[1] = lever[1] + 1;
445 # elsif ( up == -1 and lever[1] > -1){
446 # lever[1] = lever[1] - 1;
452 # if (lever[1] == 0) {
459 # print ("lever out: ", lever[0],lever[1]);
461 # setprop("controls/hydraulic/lever[1]",lever[1]);
462 # setprop("controls/hydraulic/lever[0]",lever[0]);
464 # if (lever[0] == 1 and lever[1] == -1)
465 # { registerTimer (flapBlowin)} # run the timer
467 # if (lever[0] == -1 and lever[1] != 0)
468 # { registerTimer (wheelsMove)} # run the timer
475 lever[0] = getprop("controls/hydraulic/lever[0]");
476 lever[1] = getprop("controls/hydraulic/lever[1]");
477 airspeed = getprop("velocities/airspeed-kt");
478 flap_pos = getprop("surface-positions/flap-pos-norm");
480 # print("lever: " , lever[1] , " airspeed (kts): " , airspeed , " flap pos: " , flap_pos);
483 if (lever[1] == -1 and airspeed < 105) {
484 setprop("controls/flight/flaps" , flap_pos + 0.05); # increase the flap
485 return registerTimer(flapBlowin); # run the timer
487 elsif (lever[1] == -1 and airspeed >= 110 and airspeed <= 120) {
488 flap = -0.08*airspeed + 9.4;
491 setprop("controls/flight/flaps" , flap_pos + 0.05); # flap partially blown in
493 return registerTimer(flapBlowin); # run the timer
495 elsif (lever[1] == -1 and airspeed > 120) {
499 setprop("controls/flight/flaps" , flap_pos + 0.05); # flap partially blown in
501 return registerTimer(flapBlowin); # run timer
503 if ( lever[1] == 1) {
504 setprop("controls/flight/flaps" , flap_pos - 0.05);
505 return registerTimer(flapBlowin);
509 if (flap_pos != 0 and airspeed < 110){
510 return registerTimer(flapBlowin);
512 elsif( flap_pos != 0 and airspeed >= 110 and airspeed <= 120) {
513 flap = -0.08 * airspeed + 9.4;
514 if (flap_pos > flap){
515 # print("flap: " , "flap 1");
516 setprop("controls/flight/flaps", flap); # flap partially blown in
518 return registerTimer(flapBlowin);
520 elsif (flap_pos != 0 and airspeed > 120) {
522 if (flap_pos > flap){
523 # print("flap: " , "flap 2");
524 setprop("controls/flight/flaps", flap); # flap blown in
526 # print("flap: " , "flap 2");
527 return registerTimer(flapBlowin); # run the timer
530 { # stop flap movement, don't run the timer
538 lever[0] = getprop("controls/hydraulic/lever[0]");
539 lever[1] = getprop("controls/hydraulic/lever[1]");
540 wheel_pos = getprop("gear/gear[1]/position-norm[0]");
544 if (lever[1] == -1 ) {
545 # print("levers1: " ,lever[0], lever[1] , " wheel pos: " , wheel_pos);
546 setprop("controls/hydraulic/wheels" , wheel_pos + 0.05); # lower wheels
547 return registerTimer(wheelsMove); # run the timer
549 elsif ( lever[1] == 1) {
550 # print("levers2: " ,lever[0], lever[1] , " wheel pos: " , wheel_pos);
551 setprop("controls/hydraulic/wheels" , wheel_pos - 0.05); # raise wheels
552 return registerTimer(wheelsMove);
555 { # stop wheel movement, don't run the timer
561 # =============================== end flap stuff =========================================
563 # =========================== gear warning stuff =========================================
565 toggleGearWarn = func{ # toggle the gear warning
567 cancel = getprop("sim/alarms/gear-warn");
569 # print("cancel :", cancel);
570 setprop("sim/alarms/gear-warn",cancel);
571 if (cancel) {registerTimer(resetWarn)} # run the timer
577 throttle = getprop("controls/engines/engine/throttle");
578 gearwarn = getprop("sim/alarms/gear-warn");
579 # print("throttle " , throttle , " gearwarn: " , gearwarn);
580 if (gearwarn and throttle >= 0.25 ) {
581 setprop("sim/alarms/gear-warn",0); # reset the gear warning
585 return registerTimer(resetWarn); # run the timer
591 # =========================== end gear warning stuff =========================================
593 # =============================== -ve g cutoff stuff =========================================
597 g = getprop("accelerations/pilot-g");
598 if (g == nil) { g = 0 };
599 mixture = getprop("controls/engines/engine/mixture-lever");
602 return mixture; # mixture set by lever
604 elsif (g <= 0.75 and g >= 0) { # mixture set by - ve g
607 else { # mixture set by - ve g
612 # print("g: " , g , " mixture: " , mixture);
618 # =============================== end -ve g cutoff ===========================================
620 # =============================== Pilot G stuff======================================
622 pilot_g = props.globals.getNode("accelerations/pilot-g", 1);
623 timeratio = props.globals.getNode("accelerations/timeratio", 1);
624 pilot_g_damped = props.globals.getNode("accelerations/pilot-g-damped", 1);
626 pilot_g.setDoubleValue(0);
627 pilot_g_damped.setDoubleValue(0);
628 timeratio.setDoubleValue(0.03);
632 updatePilotG = func {
633 var n = timeratio.getValue();
634 var g = pilot_g.getValue() ;
635 #if (g == nil) { g = 0; }
636 g_damp = ( g * n) + (g_damp * (1 - n));
638 pilot_g_damped.setDoubleValue(g_damp);
640 # print(sprintf("pilot_g_damped in=%0.5f, out=%0.5f", g, g_damp));
642 settimer(updatePilotG, 0.1);
644 } #end updatePilotG()
648 # headshake - this is a modification of the original work by Josh Babcock
650 # Define some stuff with global scope
660 var xDivergence_damp = 0;
661 var yDivergence_damp = 0;
662 var zDivergence_damp = 0;
664 var last_xDivergence = 0;
665 var last_yDivergence = 0;
666 var last_zDivergence = 0;
668 # Make sure that some vital data exists and set some default values
669 enabledNode = props.globals.getNode("/sim/headshake/enabled", 1);
670 enabledNode.setBoolValue(1);
672 xMaxNode = props.globals.getNode("/sim/headshake/x-max-m",1);
673 xMaxNode.setDoubleValue( 0.025 );
675 xMinNode = props.globals.getNode("/sim/headshake/x-min-m",1);
676 xMinNode.setDoubleValue( -0.05 );
678 yMaxNode = props.globals.getNode("/sim/headshake/y-max-m",1);
679 yMaxNode.setDoubleValue( 0.025 );
681 yMinNode = props.globals.getNode("/sim/headshake/y-min-m",1);
682 yMinNode.setDoubleValue( -0.025 );
684 zMaxNode = props.globals.getNode("/sim/headshake/z-max-m",1);
685 zMaxNode.setDoubleValue( 0.025 );
687 zMinNode = props.globals.getNode("/sim/headshake/z-min-m",1);
688 zMinNode.setDoubleValue( -0.05 );
690 view_number_Node = props.globals.getNode("/sim/current-view/view-number",1);
691 view_number_Node.setDoubleValue( 0 );
693 time_ratio_Node = props.globals.getNode("/sim/headshake/time-ratio",1);
694 time_ratio_Node.setDoubleValue( 0.003 );
696 seat_vertical_adjust_Node = props.globals.getNode("/controls/seat/vertical-adjust",1);
697 seat_vertical_adjust_Node.setDoubleValue( 0 );
699 xThresholdNode = props.globals.getNode("/sim/headshake/x-threshold-m",1);
700 xThresholdNode.setDoubleValue( 0.02 );
702 yThresholdNode = props.globals.getNode("/sim/headshake/y-threshold-m",1);
703 yThresholdNode.setDoubleValue( 0.02 );
705 zThresholdNode = props.globals.getNode("/sim/headshake/z-threshold-m",1);
706 zThresholdNode.setDoubleValue( 0.02 );
708 # We will use these later
709 xConfigNode = props.globals.getNode("/sim/view/config/z-offset-m");
710 yConfigNode = props.globals.getNode("/sim/view/config/x-offset-m");
711 zConfigNode = props.globals.getNode("/sim/view/config/y-offset-m");
713 xAccelNode = props.globals.getNode("/accelerations/pilot/x-accel-fps_sec",1);
714 xAccelNode.setDoubleValue( 0 );
715 yAccelNode = props.globals.getNode("/accelerations/pilot/y-accel-fps_sec",1);
716 yAccelNode.setDoubleValue( 0 );
717 zAccelNode = props.globals.getNode("/accelerations/pilot/z-accel-fps_sec",1);
718 zAccelNode.setDoubleValue(-32 );
723 # First, we don't shake outside the vehicle. Inside, we boogie down.
724 # There are two coordinate systems here, one used for accelerations, and one used for the viewpoint.
725 # We will be using the one for accelerations.
726 var enabled = enabledNode.getValue();
727 var view_number= view_number_Node.getValue();
728 var n = timeratio.getValue();
729 var seat_vertical_adjust = seat_vertical_adjust_Node.getValue();
732 if ( (enabled) and ( view_number == 0)) {
734 var xConfig = xConfigNode.getValue();
735 var yConfig = yConfigNode.getValue();
736 var zConfig = zConfigNode.getValue();
738 var xMax = xMaxNode.getValue();
739 var xMin = xMinNode.getValue();
740 var yMax = yMaxNode.getValue();
741 var yMin = yMinNode.getValue();
742 var zMax = zMaxNode.getValue();
743 var zMin = zMinNode.getValue();
745 #work in G, not fps/s
746 var xAccel = xAccelNode.getValue()/32;
747 var yAccel = yAccelNode.getValue()/32;
748 var zAccel = (zAccelNode.getValue() + 32)/32; # We aren't counting gravity
750 var xThreshold = xThresholdNode.getValue();
751 var yThreshold = yThresholdNode.getValue();
752 var zThreshold = zThresholdNode.getValue();
754 # Set viewpoint divergence and clamp
755 # Note that each dimension has it's own special ratio and +X is clamped at 1cm
756 # to simulate a headrest.
758 #y = -0.0005x3 - 0.005x2 - 0.0089x - 0.0045
759 # -0.0004x3 + 0.0042x2 - 0.0084x + 0.0048
760 # -0.0004x3 - 0.0042x2 - 0.0084x - 0.0048
763 } elsif ((xAccel < -0.5) and (xAccel >= -5)) {
764 xDivergence = ((( -0.0005 * xAccel ) - ( 0.0036 )) * xAccel - ( 0.001 )) * xAccel - 0.0004;
765 } elsif ((xAccel > 1) and (xAccel <= 6)) {
766 xDivergence = ((( -0.0004 * xAccel ) + ( 0.0031 )) * xAccel - ( 0.0016 )) * xAccel + 0.0002;
767 } elsif (xAccel > 5) {
773 # These equations shape the output and convet from G number to divergence left/right in meters
774 # y = -0.0005x3 - 0.0036x2 + 0.0001x + 0.0004
775 # y = -0.013x3 + 0.125x2 - 0.1202x + 0.0272
779 } elsif ((yAccel < -0.5) and (yAccel >= -5)) {
780 yDivergence = ((( -0.005 * yAccel ) - ( 0.0036 )) * yAccel - ( 0.0001 )) * yAccel - 0.0004;
781 } elsif ((yAccel > 0.5) and (yAccel <= 5)) {
782 yDivergence = ((( -0.013 * yAccel ) + ( 0.125 )) * yAccel - ( 0.1202 )) * yAccel + 0.0272;
783 } elsif (yAccel > 5) {
789 # setprop("/sim/current-view/x-offset-m", (yConfig + yDivergence));
790 # y = -0.0005x3 - 0.0036x2 + 0.0001x + 0.0004
791 # y = -0.0004x3 + 0.0031x2 - 0.0016x + 0.0002
794 } elsif ((zAccel < -0.5) and (zAccel >= -5)) {
795 zDivergence = ((( -0.0005 * zAccel ) - ( 0.0036 )) * zAccel - ( 0.001 )) * zAccel - 0.0004;
796 } elsif ((zAccel > 0.5) and (zAccel <= 5)) {
797 zDivergence = ((( -0.0004 * zAccel ) + ( 0.0031 )) * zAccel - ( 0.0016 )) * zAccel + 0.0002;
798 } elsif (zAccel > 5) {
805 xDivergence_total = (xDivergence * 0.75) + (zDivergence * 0.25);
807 if (xDivergence_total > xMax){xDivergence_total = xMax;}
808 if (xDivergence_total < xMin){xDivergence_total = xMin;}
810 if (abs(last_xDivergence - xDivergence_total) <= xThreshold){
811 xDivergence_damp = ( xDivergence_total * n) + ( xDivergence_damp * (1 - n));
812 # print ("x low pass");
814 xDivergence_damp = xDivergence_total;
815 # print ("x high pass");
818 last_xDivergence = xDivergence_damp;
820 # print (sprintf("x-G=%0.5fx, total=%0.5f, x div damped=%0.5f",xAccel, xDivergence_total, xDivergence_damp));
822 yDivergence_total = yDivergence;
823 if (yDivergence_total >= yMax){yDivergence_total = yMax;}
824 if (yDivergence_total <= yMin){yDivergence_total = yMin;}
826 if (abs(last_yDivergence - yDivergence_total) <= yThreshold){
827 yDivergence_damp = ( yDivergence_total * n) + ( yDivergence_damp * (1 - n));
828 # print ("y low pass");
830 yDivergence_damp = yDivergence_total;
831 # print ("y high pass");
834 last_yDivergence = yDivergence_damp;
836 #print (sprintf("y=%0.5f, y total=%0.5f, y min=%0.5f, y div damped=%0.5f",yDivergence, yDivergence_total, yMin , yDivergence_damp));
838 zDivergence_total = (xDivergence * 0.25 ) + (zDivergence * 0.75);
840 if (zDivergence_total >= zMax){zDivergence_total = zMax;}
841 if (zDivergence_total <= zMin){zDivergence_total = zMin;}
843 if (abs(last_zDivergence - zDivergence_total) <= zThreshold){
844 zDivergence_damp = ( zDivergence_total * n) + ( zDivergence_damp * (1 - n));
845 #print ("z low pass");
847 zDivergence_damp = zDivergence_total;
848 #print ("z high pass");
852 # last_zDivergence = zDivergence_damp;
854 #print (sprintf("z-G=%0.5f, z total=%0.5f, z div damped=%0.5f",zAccel, zDivergence_total,zDivergence_damp));
856 setprop("/sim/current-view/z-offset-m", xConfig + xDivergence_damp );
857 setprop("/sim/current-view/x-offset-m", yConfig + yDivergence_damp );
858 setprop("/sim/current-view/y-offset-m", zConfig + zDivergence_damp + seat_vertical_adjust );
860 settimer(headShake,0 );
866 # ======================================= end Pilot G stuff ============================
868 # ================================== Steering ==========================================
870 aircraft.steering.init();
873 # ================================== Engine Hobbs Meter ================================
875 var hobbs_engine = aircraft.timer.new("sim/time/hobbs/engine[0]", 60, 0);
876 var engine_running_Node = props.globals.initNode("engines/engine[0]/running", 1, "BOOL");
878 hobbs_engine.reset();
881 var running = engine_running_Node.getValue();
884 hobbs_engine.start();
889 settimer(updateHobbs,0)
894 # ================================== End Engine Hobbs Meter ================================
896 # ================================== Tyresmoke /Spray ================================
897 var run_tyresmoke0 = 0;
898 var run_tyresmoke1 = 0;
899 var run_tyresmoke2 = 0;
901 var tyresmoke_0 = aircraft.tyresmoke.new(0);
902 var tyresmoke_1 = aircraft.tyresmoke.new(1);
903 var tyresmoke_2 = aircraft.tyresmoke.new(2);
905 # =============================== listeners ===============================
908 setlistener( "controls/lighting/nav-lights", func {
909 var nav_lights_node = props.globals.getNode("controls/lighting/nav-lights", 1);
910 var generic_node = props.globals.getNode("sim/multiplay/generic/int[0]", 1);
911 generic_node.setIntValue(nav_lights_node.getValue());
912 print("nav_lights ", nav_lights_node.getValue(), "generic_node ", generic_node.getValue());
916 setlistener("gear/gear[0]/position-norm", func {
917 var gear = getprop("gear/gear[0]/position-norm");
929 setlistener("gear/gear[1]/position-norm", func {
930 var gear = getprop("gear/gear[1]/position-norm");
942 setlistener("gear/gear[2]/position-norm", func {
943 var gear = getprop("gear/gear[2]/position-norm");
955 #============================ Tyre Smoke ===================================
957 var tyresmoke = func {
959 #print ("run_tyresmoke ",run_tyresmoke0,run_tyresmoke1,run_tyresmoke2);
962 tyresmoke_0.update();
965 tyresmoke_1.update();
968 tyresmoke_2.update();
970 settimer(tyresmoke, 0);
977 #============================ Rain ===================================
979 aircraft.rain.init();
982 var running = engine_running_Node.getValue();
983 aircraft.rain.update();
984 # print("running ", running);
987 setprop("sim/model/rain/flow-threshold-kt", 0);
989 setprop("sim/model/rain/flow-threshold-kt", 15);