2017-05-29 16:30:05 +00:00
# A320 Main Libraries
2019-05-08 23:27:26 +00:00
# Joshua Davidson (Octal450)
2017-04-25 18:41:13 +00:00
2019-05-08 23:27:26 +00:00
# Copyright (c) 2019 Joshua Davidson (Octal450)
2017-07-13 17:30:33 +00:00
print("-----------------------------------------------------------------------------");
2019-05-08 23:27:26 +00:00
print("Copyright (c) 2016-2019 Joshua Davidson (Octal450)");
2017-07-13 17:30:33 +00:00
print("-----------------------------------------------------------------------------");
2017-04-25 18:41:13 +00:00
2018-06-09 22:48:02 +00:00
setprop("/sim/replay/was-active", 0);
2018-12-30 21:28:02 +00:00
setprop("/sim/menubar/default/menu[0]/item[0]/enabled", 0);
setprop("/sim/menubar/default/menu[2]/item[0]/enabled", 0);
setprop("/sim/menubar/default/menu[2]/item[2]/enabled", 0);
setprop("/sim/menubar/default/menu[3]/enabled", 0);
setprop("/sim/menubar/default/menu[5]/item[9]/enabled", 0);
setprop("/sim/menubar/default/menu[5]/item[10]/enabled", 0);
setprop("/sim/menubar/default/menu[5]/item[11]/enabled", 0);
2017-06-29 15:29:10 +00:00
# Dimmers
2017-08-04 17:59:05 +00:00
setprop("/controls/lighting/ndl-norm", 1);
setprop("/controls/lighting/ndr-norm", 1);
setprop("/controls/lighting/upper-norm", 1);
2017-06-29 15:29:10 +00:00
2017-08-03 18:31:12 +00:00
# Lights
2017-08-04 17:59:05 +00:00
setprop("/sim/model/lights/nose-lights", 0);
setprop("/sim/model/lights/turnoffsw", 0);
2017-12-01 19:44:20 +00:00
setprop("/controls/lighting/turnoff-light-switch", 0);
2017-12-01 19:37:53 +00:00
setprop("/controls/lighting/leftturnoff", 0);
setprop("/controls/lighting/rightturnoff", 0);
2017-08-03 18:31:12 +00:00
2017-07-07 00:12:05 +00:00
# Oil Qty
var qty1 = math.round((rand() * 5 ) + 20, 0.1);
var qty2 = math.round((rand() * 5 ) + 20, 0.1);
setprop("/engines/engine[0]/oil-qt-actual", qty1);
setprop("/engines/engine[1]/oil-qt-actual", qty2);
2017-04-25 18:41:13 +00:00
##########
# Lights #
##########
2018-10-21 20:50:52 +00:00
2018-11-19 14:18:06 +00:00
var beacon_switch = props.globals.getNode("/controls/switches/beacon", 1);
2019-02-18 20:53:32 +00:00
var beacon_ctl = props.globals.getNode("/controls/lighting/beacon", 1);
2017-12-11 20:23:11 +00:00
var beacon = aircraft.light.new("/sim/model/lights/beacon", [0.1, 1], "/controls/lighting/beacon");
2018-11-19 14:18:06 +00:00
var strobe_switch = props.globals.getNode("/controls/switches/strobe", 1);
var strobe_light = props.globals.getNode("/controls/lighting/strobe", 1);
2017-11-09 02:16:40 +00:00
var strobe = aircraft.light.new("/sim/model/lights/strobe", [0.05, 0.06, 0.05, 1], "/controls/lighting/strobe");
2017-12-11 20:23:11 +00:00
var tail_strobe = aircraft.light.new("/sim/model/lights/tailstrobe", [0.1, 1], "/controls/lighting/strobe");
2017-08-05 12:22:02 +00:00
var logo_lights = getprop("/sim/model/lights/logo-lights");
2017-12-02 22:18:09 +00:00
var nav_lights = props.globals.getNode("/sim/model/lights/nav-lights");
2019-02-18 20:53:32 +00:00
var wing_switch = props.globals.getNode("/controls/switches/wing-lights", 1);
var wing_ctl = props.globals.getNode("/controls/lighting/wing-lights", 1);
2018-10-20 15:56:31 +00:00
var dome_light = props.globals.initNode("/sim/model/lights/dome-light", 0.0, "DOUBLE");
2017-08-05 12:22:02 +00:00
var wow = getprop("/gear/gear[2]/wow");
var slats = getprop("/controls/flight/slats");
2017-12-02 22:18:09 +00:00
var gear = getprop("/gear/gear[0]/position-norm");
var nose_lights = getprop("/sim/model/lights/nose-lights");
var left_turnoff_light = props.globals.getNode("/controls/lighting/leftturnoff");
var right_turnoff_light = props.globals.getNode("/controls/lighting/rightturnoff");
var settingT = getprop("/controls/lighting/taxi-light-switch");
var settingTurnoff = getprop("/controls/lighting/turnoff-light-switch");
var setting = getprop("/controls/lighting/nav-lights-switch");
2018-10-20 15:56:31 +00:00
var domeSetting = getprop("/controls/lighting/dome-norm");
2019-02-18 20:53:32 +00:00
var landL = props.globals.getNode("controls/lighting/landing-lights[1]", 1);
var landR = props.globals.getNode("controls/lighting/landing-lights[2]", 1);
var landlSw = props.globals.getNode("/controls/switches/landing-lights-l", 1);
var landrSw = props.globals.getNode("/controls/switches/landing-lights-r", 1);
2017-04-25 18:41:13 +00:00
###################
# Tire Smoke/Rain #
###################
var tiresmoke_system = aircraft.tyresmoke_system.new(0, 1, 2);
aircraft.rain.init();
##########
# Sounds #
##########
2017-05-29 16:30:05 +00:00
setlistener("/sim/sounde/btn1", func {
if (!getprop("/sim/sounde/btn1")) {
return;
}
settimer(func {
props.globals.getNode("/sim/sounde/btn1").setBoolValue(0);
}, 0.05);
});
2017-06-17 04:17:06 +00:00
setlistener("/sim/sounde/oh-btn", func {
if (!getprop("/sim/sounde/oh-btn")) {
return;
}
settimer(func {
props.globals.getNode("/sim/sounde/oh-btn").setBoolValue(0);
}, 0.05);
});
setlistener("/sim/sounde/btn3", func {
if (!getprop("/sim/sounde/btn3")) {
return;
}
settimer(func {
props.globals.getNode("/sim/sounde/btn3").setBoolValue(0);
}, 0.05);
});
2017-05-29 16:30:05 +00:00
setlistener("/sim/sounde/knb1", func {
if (!getprop("/sim/sounde/knb1")) {
return;
}
settimer(func {
props.globals.getNode("/sim/sounde/knb1").setBoolValue(0);
}, 0.05);
});
2017-06-05 19:59:40 +00:00
setlistener("/sim/sounde/switch1", func {
if (!getprop("/sim/sounde/switch1")) {
return;
}
settimer(func {
props.globals.getNode("/sim/sounde/switch1").setBoolValue(0);
}, 0.05);
});
2018-11-19 14:18:06 +00:00
setlistener("/controls/lighting/seatbelt-sign", func {
2017-04-25 18:41:13 +00:00
props.globals.getNode("/sim/sounde/seatbelt-sign").setBoolValue(1);
settimer(func {
props.globals.getNode("/sim/sounde/seatbelt-sign").setBoolValue(0);
}, 2);
2018-11-19 14:18:06 +00:00
}, 0, 0);
2017-04-25 18:41:13 +00:00
2018-11-19 14:18:06 +00:00
setlistener("/controls/lighting/no-smoking-sign", func {
2017-04-25 18:41:13 +00:00
props.globals.getNode("/sim/sounde/no-smoking-sign").setBoolValue(1);
settimer(func {
props.globals.getNode("/sim/sounde/no-smoking-sign").setBoolValue(0);
2017-06-17 04:17:06 +00:00
}, 1);
2018-11-19 14:18:06 +00:00
}, 0, 0);
2017-04-25 18:41:13 +00:00
2019-05-08 10:00:14 +00:00
setlistener("/controls/flight/flap-lever", func {
props.globals.getNode("/sim/sounde/flaps-click").setBoolValue(1);
}, 0, 0);
setlistener("/sim/sounde/flaps-click", func {
if (!getprop("/sim/sounde/flaps-click")) {
return;
}
settimer(func {
props.globals.getNode("/sim/sounde/flaps-click").setBoolValue(0);
}, 0.4);
});
2017-05-03 00:54:39 +00:00
#########
# Doors #
#########
2017-04-25 18:41:13 +00:00
# Front doors
2017-08-07 15:25:11 +00:00
var doorl1 = aircraft.door.new("/sim/model/door-positions/doorl1", 4);
var doorr1 = aircraft.door.new("/sim/model/door-positions/doorr1", 4);
2017-04-25 18:41:13 +00:00
# Middle doors (A321 only)
2017-08-07 15:25:11 +00:00
var doorl2 = aircraft.door.new("/sim/model/door-positions/doorl2", 4);
var doorr2 = aircraft.door.new("/sim/model/door-positions/doorr2", 4);
var doorl3 = aircraft.door.new("/sim/model/door-positions/doorl3", 4);
var doorr3 = aircraft.door.new("/sim/model/door-positions/doorr3", 4);
2017-04-25 18:41:13 +00:00
# Rear doors
2017-08-07 15:25:11 +00:00
var doorl4 = aircraft.door.new("/sim/model/door-positions/doorl4", 4);
var doorr4 = aircraft.door.new("/sim/model/door-positions/doorr4", 4);
2017-04-25 18:41:13 +00:00
# Cargo holds
2017-08-07 15:25:11 +00:00
var cargobulk = aircraft.door.new("/sim/model/door-positions/cargobulk", 3);
var cargoaft = aircraft.door.new("/sim/model/door-positions/cargoaft", 10);
var cargofwd = aircraft.door.new("/sim/model/door-positions/cargofwd", 10);
2017-04-25 18:41:13 +00:00
# Seat armrests in the flight deck (unused)
var armrests = aircraft.door.new("/sim/model/door-positions/armrests", 2);
# door opener/closer
var triggerDoor = func(door, doorName, doorDesc) {
if (getprop("/sim/model/door-positions/" ~ doorName ~ "/position-norm") > 0) {
gui.popupTip("Closing " ~ doorDesc ~ " door");
door.toggle();
} else {
if (getprop("/velocities/groundspeed-kt") > 5) {
2017-11-09 16:30:40 +00:00
gui.popupTip("You cannot open the doors while the aircraft is moving!");
2017-04-25 18:41:13 +00:00
} else {
gui.popupTip("Opening " ~ doorDesc ~ " door");
door.toggle();
}
}
};
2017-05-27 19:58:19 +00:00
#######################
# Various Other Stuff #
#######################
2017-12-30 04:44:41 +00:00
var systemsInit = func {
2017-06-10 15:57:48 +00:00
fbw.fctlInit();
2017-11-21 16:21:42 +00:00
systems.ELEC.init();
systems.PNEU.init();
systems.HYD.init();
systems.FUEL.init();
systems.ADIRS.init();
2017-07-03 18:26:43 +00:00
systems.eng_init();
2017-11-21 16:21:42 +00:00
systems.fire_init();
2017-10-04 19:53:07 +00:00
systems.autobrake_init();
2018-09-28 20:12:28 +00:00
fadec.FADEC.init();
2019-03-17 02:44:34 +00:00
fmgc.ITAF.init();
2017-05-13 13:24:02 +00:00
fmgc.FMGCinit();
2018-08-29 21:34:11 +00:00
mcdu.MCDU_init(0);
mcdu.MCDU_init(1);
2017-12-02 22:18:09 +00:00
systemsLoop.start();
2017-06-21 17:21:27 +00:00
icing.icingInit();
2017-12-02 22:18:09 +00:00
lightsLoop.start();
2017-12-30 04:44:41 +00:00
libraries.ECAM.init();
2018-09-14 15:12:06 +00:00
libraries.BUTTONS.init();
2017-06-02 02:57:14 +00:00
libraries.variousReset();
2018-09-26 18:42:57 +00:00
rmp.init();
2018-10-21 15:12:35 +00:00
acp.init();
2018-11-21 21:17:21 +00:00
ecam.ECAM_controller.init();
2019-05-29 16:31:25 +00:00
atc.init();
2017-12-30 04:44:41 +00:00
}
setlistener("/sim/signals/fdm-initialized", func {
systemsInit();
2017-04-25 18:41:13 +00:00
});
2017-11-21 16:21:42 +00:00
var systemsLoop = maketimer(0.1, func {
systems.ELEC.loop();
systems.PNEU.loop();
systems.HYD.loop();
systems.FUEL.loop();
systems.ADIRS.loop();
2017-12-30 04:44:41 +00:00
libraries.ECAM.loop();
2018-09-14 15:12:06 +00:00
libraries.BUTTONS.update();
2018-09-28 20:12:28 +00:00
fadec.FADEC.loop();
2018-10-21 20:47:55 +00:00
rmp.rmpUpdate();
2018-06-09 22:48:02 +00:00
2017-10-06 03:35:36 +00:00
if ((getprop("/controls/pneumatic/switches/groundair") or getprop("/controls/switches/cart")) and ((getprop("/velocities/groundspeed-kt") > 2) or getprop("/controls/gear/brake-parking") == 0)) {
2017-06-05 19:59:40 +00:00
setprop("/controls/switches/cart", 0);
setprop("/controls/pneumatic/switches/groundair", 0);
}
2017-07-12 21:31:04 +00:00
if (getprop("/velocities/groundspeed-kt") > 15) {
2017-06-05 19:59:40 +00:00
setprop("/systems/shake/effect", 1);
} else {
setprop("/systems/shake/effect", 0);
}
2017-06-19 19:44:00 +00:00
2017-12-29 23:37:07 +00:00
if (getprop("/instrumentation/mk-viii/inputs/discretes/momentary-flap-all-override") == 1 or (getprop("/instrumentation/mk-viii/inputs/discretes/momentary-flap-3-override") == 1 and getprop("/controls/flight/flap-pos") >= 4)) {
setprop("/instrumentation/mk-viii/inputs/discretes/momentary-flap-override", 1);
} else {
setprop("/instrumentation/mk-viii/inputs/discretes/momentary-flap-override", 0);
}
2018-01-01 15:11:46 +00:00
if (getprop("/instrumentation/mk-viii/inputs/discretes/gpws-inhibit") == 1) {
setprop("/instrumentation/mk-viii/speaker/volume", 0);
} else {
setprop("/instrumentation/mk-viii/speaker/volume", 2);
}
2018-01-16 20:21:32 +00:00
if (getprop("/engines/engine[0]/state") == 3 and getprop("/engines/engine[1]/state") == 3) {
setprop("/engines/ready", 1);
} else {
setprop("/engines/ready", 0);
}
2018-04-03 17:46:19 +00:00
if ((getprop("/engines/engine[0]/state") == 2 or getprop("/engines/engine[0]/state") == 3) and getprop("/fdm/jsbsim/propulsion/tank[3]/contents-lbs") < 1) {
systems.cutoff_one();
}
if ((getprop("/engines/engine[1]/state") == 2 or getprop("/engines/engine[1]/state") == 3) and getprop("/fdm/jsbsim/propulsion/tank[4]/contents-lbs") < 1) {
systems.cutoff_two();
}
2018-06-09 22:48:02 +00:00
if (getprop("/sim/replay/replay-state") == 1) {
setprop("/sim/replay/was-active", 1);
} else if (getprop("/sim/replay/replay-state") == 0 and getprop("/sim/replay/was-active") == 1) {
setprop("/sim/replay/was-active", 0);
acconfig.colddark();
gui.popupTip("Replay Ended: Setting Cold and Dark state...");
}
2017-06-05 19:59:40 +00:00
});
2017-07-02 14:45:39 +00:00
setlistener("/options/steep-ils", func {
if (getprop("/options/steep-ils") == 1) {
setprop("/instrumentation/mk-viii/inputs/discretes/steep-approach", 1);
} else {
setprop("/instrumentation/mk-viii/inputs/discretes/steep-approach", 0);
}
});
2017-06-02 02:57:14 +00:00
2017-09-27 20:04:39 +00:00
canvas.Text._lastText = canvas.Text["_lastText"];
2017-12-29 23:37:07 +00:00
canvas.Text.setText = func(text) {
2019-02-12 16:11:16 +00:00
if (text == me._lastText and text != nil and size(text) == size(me._lastText)) {return me;}
2017-09-27 20:04:39 +00:00
me._lastText = text;
2017-09-27 19:21:28 +00:00
me.set("text", typeof(text) == 'scalar' ? text : "");
2017-09-24 14:11:49 +00:00
};
2017-09-29 22:04:31 +00:00
canvas.Element._lastVisible = nil;
2017-12-29 23:37:07 +00:00
canvas.Element.show = func {
2017-09-27 19:21:28 +00:00
if (1 == me._lastVisible) {return me;}
me._lastVisible = 1;
me.setBool("visible", 1);
2017-09-24 14:11:49 +00:00
};
2017-12-29 23:37:07 +00:00
canvas.Element.hide = func {
2017-09-27 19:21:28 +00:00
if (0 == me._lastVisible) {return me;}
me._lastVisible = 0;
me.setBool("visible", 0);
2017-09-24 14:11:49 +00:00
};
2017-12-29 23:37:07 +00:00
canvas.Element.setVisible = func(vis) {
2017-09-27 19:21:28 +00:00
if (vis == me._lastVisible) {return me;}
me._lastVisible = vis;
me.setBool("visible", vis);
2017-09-27 19:17:20 +00:00
};
2017-09-24 14:11:49 +00:00
2017-06-02 00:53:50 +00:00
# In air, flaps 1 is slats only. On ground, it is slats and flaps.
setprop("/controls/flight/flap-lever", 0);
setprop("/controls/flight/flap-pos", 0);
setprop("/controls/flight/flap-txt", " ");
controls.flapsDown = func(step) {
if (step == 1) {
if (getprop("/controls/flight/flap-lever") == 0) {
if (getprop("/velocities/airspeed-kt") <= 100) {
setprop("/controls/flight/flaps", 0.290);
setprop("/controls/flight/slats", 0.666);
setprop("/controls/flight/flap-lever", 1);
setprop("/controls/flight/flap-pos", 2);
setprop("/controls/flight/flap-txt", "1+F");
flaptimer.start();
return;
} else {
setprop("/controls/flight/flaps", 0.000);
setprop("/controls/flight/slats", 0.666);
setprop("/controls/flight/flap-lever", 1);
setprop("/controls/flight/flap-pos", 1);
setprop("/controls/flight/flap-txt", "1");
flaptimer.stop();
return;
}
} else if (getprop("/controls/flight/flap-lever") == 1) {
setprop("/controls/flight/flaps", 0.596);
setprop("/controls/flight/slats", 0.814);
setprop("/controls/flight/flap-lever", 2);
setprop("/controls/flight/flap-pos", 3);
setprop("/controls/flight/flap-txt", "2");
flaptimer.stop();
return;
} else if (getprop("/controls/flight/flap-lever") == 2) {
setprop("/controls/flight/flaps", 0.645);
setprop("/controls/flight/slats", 0.814);
setprop("/controls/flight/flap-lever", 3);
setprop("/controls/flight/flap-pos", 4);
setprop("/controls/flight/flap-txt", "3");
flaptimer.stop();
return;
} else if (getprop("/controls/flight/flap-lever") == 3) {
setprop("/controls/flight/flaps", 1.000);
setprop("/controls/flight/slats", 1.000);
setprop("/controls/flight/flap-lever", 4);
setprop("/controls/flight/flap-pos", 5);
setprop("/controls/flight/flap-txt", "FULL");
flaptimer.stop();
return;
}
} else if (step == -1) {
if (getprop("/controls/flight/flap-lever") == 4) {
setprop("/controls/flight/flaps", 0.645);
setprop("/controls/flight/slats", 0.814);
setprop("/controls/flight/flap-lever", 3);
setprop("/controls/flight/flap-pos", 4);
setprop("/controls/flight/flap-txt", "3");
flaptimer.stop();
return;
} else if (getprop("/controls/flight/flap-lever") == 3) {
setprop("/controls/flight/flaps", 0.596);
setprop("/controls/flight/slats", 0.814);
setprop("/controls/flight/flap-lever", 2);
setprop("/controls/flight/flap-pos", 3);
setprop("/controls/flight/flap-txt", "2");
flaptimer.stop();
return;
} else if (getprop("/controls/flight/flap-lever") == 2) {
if (getprop("/velocities/airspeed-kt") <= 100) {
setprop("/controls/flight/flaps", 0.290);
setprop("/controls/flight/slats", 0.666);
setprop("/controls/flight/flap-lever", 1);
setprop("/controls/flight/flap-pos", 2);
setprop("/controls/flight/flap-txt", "1+F");
flaptimer.start();
return;
} else {
setprop("/controls/flight/flaps", 0.000);
setprop("/controls/flight/slats", 0.666);
setprop("/controls/flight/flap-lever", 1);
setprop("/controls/flight/flap-pos", 1);
setprop("/controls/flight/flap-txt", "1");
flaptimer.stop();
return;
}
} else if (getprop("/controls/flight/flap-lever") == 1) {
setprop("/controls/flight/flaps", 0.000);
setprop("/controls/flight/slats", 0.000);
setprop("/controls/flight/flap-lever", 0);
setprop("/controls/flight/flap-pos", 0);
setprop("/controls/flight/flap-txt", " ");
flaptimer.stop();
return;
}
} else {
return 0;
}
}
var flaptimer = maketimer(0.5, func {
if (getprop("/controls/flight/flap-pos") == 2 and getprop("/velocities/airspeed-kt") >= 208) {
setprop("/controls/flight/flaps", 0.000);
setprop("/controls/flight/slats", 0.666);
setprop("/controls/flight/flap-lever", 1);
setprop("/controls/flight/flap-pos", 1);
setprop("/controls/flight/flap-txt", "1");
flaptimer.stop();
}
});
2017-08-04 17:59:05 +00:00
2018-07-22 16:14:32 +00:00
controls.stepSpoilers = func(step) {
setprop("/controls/flight/speedbrake-arm", 0);
if (step == 1) {
deploySpeedbrake();
} else if (step == -1) {
retractSpeedbrake();
}
}
var deploySpeedbrake = func {
2018-07-22 16:19:58 +00:00
if (getprop("/gear/gear[1]/wow") == 1 or getprop("/gear/gear[2]/wow") == 1) {
if (getprop("/controls/flight/speedbrake") < 1.0) {
setprop("/controls/flight/speedbrake", 1.0);
}
} else {
if (getprop("/controls/flight/speedbrake") < 0.5) {
setprop("/controls/flight/speedbrake", 0.5);
} else if (getprop("/controls/flight/speedbrake") < 1.0) {
setprop("/controls/flight/speedbrake", 1.0);
}
2018-07-22 16:14:32 +00:00
}
}
var retractSpeedbrake = func {
2018-07-22 16:19:58 +00:00
if (getprop("/gear/gear[1]/wow") == 1 or getprop("/gear/gear[2]/wow") == 1) {
if (getprop("/controls/flight/speedbrake") > 0.0) {
setprop("/controls/flight/speedbrake", 0.0);
}
} else {
if (getprop("/controls/flight/speedbrake") > 0.5) {
setprop("/controls/flight/speedbrake", 0.5);
} else if (getprop("/controls/flight/speedbrake") > 0.0) {
setprop("/controls/flight/speedbrake", 0.0);
}
2018-07-22 16:14:32 +00:00
}
}
2017-12-20 19:58:33 +00:00
var slewProp = func(prop, delta) {
delta *= getprop("/sim/time/delta-realtime-sec");
setprop(prop, getprop(prop) + delta);
return getprop(prop);
}
controls.elevatorTrim = func(speed) {
if (getprop("/systems/hydraulic/green-psi") >= 1500) {
slewProp("/controls/flight/elevator-trim", speed * 0.045);
}
}
setlistener("/controls/flight/elevator-trim", func {
if (getprop("/controls/flight/elevator-trim") > 0.32) {
setprop("/controls/flight/elevator-trim", 0.32);
}
});
2017-12-02 22:18:09 +00:00
var lightsLoop = maketimer(0.2, func {
gear = getprop("/gear/gear[0]/position-norm");
nose_lights = getprop("/sim/model/lights/nose-lights");
settingT = getprop("/controls/lighting/taxi-light-switch");
2018-10-20 15:56:31 +00:00
domeSetting = getprop("/controls/lighting/dome-norm");
2017-12-02 22:18:09 +00:00
# nose lights
2017-12-03 13:19:40 +00:00
2017-12-11 20:23:11 +00:00
if (settingT == 0.5 and gear > 0.9 and (getprop("/systems/electrical/bus/ac1") > 0 or getprop("/systems/electrical/bus/ac2") > 0)) {
2017-12-02 22:18:09 +00:00
setprop("/sim/model/lights/nose-lights", 0.85);
2017-12-11 20:23:11 +00:00
} else if (settingT == 1 and gear > 0.9 and (getprop("/systems/electrical/bus/ac1") > 0 or getprop("/systems/electrical/bus/ac2") > 0)) {
2017-12-02 22:18:09 +00:00
setprop("/sim/model/lights/nose-lights", 1);
} else {
setprop("/sim/model/lights/nose-lights", 0);
}
# turnoff lights
2017-12-03 13:19:40 +00:00
settingTurnoff = getprop("/controls/lighting/turnoff-light-switch");
left_turnoff_light = props.globals.getNode("/controls/lighting/leftturnoff");
right_turnoff_light = props.globals.getNode("/controls/lighting/rightturnoff");
2017-12-11 20:23:11 +00:00
if (settingTurnoff == 1 and gear > 0.9 and getprop("/systems/electrical/bus/ac1") > 0) {
2017-12-02 22:18:09 +00:00
left_turnoff_light.setBoolValue(1);
} else {
left_turnoff_light.setBoolValue(0);
2017-12-11 20:23:11 +00:00
}
if (settingTurnoff == 1 and gear > 0.9 and getprop("/systems/electrical/bus/ac2") > 0) {
right_turnoff_light.setBoolValue(1);
} else {
2017-12-02 22:18:09 +00:00
right_turnoff_light.setBoolValue(0);
}
2017-12-03 13:19:40 +00:00
# logo and navigation lights
setting = getprop("/controls/lighting/nav-lights-switch");
nav_lights = props.globals.getNode("/sim/model/lights/nav-lights");
logo_lights = props.globals.getNode("/sim/model/lights/logo-lights");
wow = getprop("/gear/gear[2]/wow");
slats = getprop("/controls/flight/slats");
2019-02-18 20:53:32 +00:00
if (getprop("/systems/electrical/bus/ac1") > 0 or getprop("/systems/electrical/bus/ac2") > 0 or getprop("/systems/electrical/bus/dc1") > 0 or getprop("/systems/electrical/bus/dc2") > 0) {
2017-12-11 20:23:11 +00:00
setprop("/systems/electrical/nav-lights-power", 1);
} else {
setprop("/systems/electrical/nav-lights-power", 0);
}
2017-08-05 12:22:02 +00:00
if (setting == 0 and logo_lights == 1) {
2017-12-03 13:19:40 +00:00
logo_lights.setBoolValue(0);
2017-12-11 20:23:11 +00:00
} else if (setting == 1 or setting == 2 and (getprop("/systems/electrical/bus/ac1") > 0 or getprop("/systems/electrical/bus/ac2") > 0)) {
2017-12-03 13:19:40 +00:00
if ((wow) or (!wow and slats > 0)) {
logo_lights.setBoolValue(1);
2017-08-04 17:59:05 +00:00
} else {
2017-12-03 13:19:40 +00:00
logo_lights.setBoolValue(0);
2017-08-04 17:59:05 +00:00
}
2017-12-03 13:19:40 +00:00
} else {
logo_lights.setBoolValue(0);
2017-08-04 17:59:05 +00:00
}
2017-12-03 13:19:40 +00:00
2017-12-11 20:23:11 +00:00
if (setting == 1 or setting == 2 and (getprop("/systems/electrical/bus/ac1") > 0 or getprop("/systems/electrical/bus/ac2") > 0 or getprop("/systems/electrical/bus/dc1") > 0 or getprop("/systems/electrical/bus/dc2") > 0)) {
2017-12-02 22:18:09 +00:00
nav_lights.setBoolValue(1);
2017-08-04 17:59:05 +00:00
} else {
2017-12-02 22:18:09 +00:00
nav_lights.setBoolValue(0);
2017-08-04 17:59:05 +00:00
}
2018-11-19 14:18:06 +00:00
2018-10-20 15:56:31 +00:00
if (domeSetting == 0.5 and getprop("/systems/electrical/bus/dc-ess") > 0) {
dome_light.setValue(0.5);
} elsif (domeSetting == 1 and getprop("/systems/electrical/bus/dc-ess") > 0) {
dome_light.setValue(1);
} else {
dome_light.setValue(0);
}
2019-01-01 16:53:41 +00:00
2018-11-19 14:18:06 +00:00
# strobe
strobe_sw = strobe_switch.getValue();
2019-02-18 20:53:32 +00:00
if (strobe_sw == 1 and getprop("/systems/electrical/bus/ac2") > 0) {
2018-11-19 14:18:06 +00:00
strobe_light.setValue(1);
2019-02-18 20:53:32 +00:00
} elsif (strobe_sw == 0.5 and getprop("/gear/gear[1]/wow") == 0 and getprop("/gear/gear[2]/wow") == 0 and getprop("/systems/electrical/bus/ac2") > 0) {
2018-11-19 14:18:06 +00:00
# todo: use lgciu output 5
strobe_light.setValue(1);
} else {
strobe_light.setValue(0);
}
2019-02-18 20:53:32 +00:00
# beacon
if (beacon_switch.getValue() == 1 and (getprop("/systems/electrical/bus/ac1") > 0 or getprop("/systems/electrical/bus/ac2") > 0)) {
beacon_ctl.setValue(1);
} else {
beacon_ctl.setValue(0);
}
# wing
if (wing_switch.getValue() == 1 and (getprop("/systems/electrical/bus/ac1") > 0 or getprop("/systems/electrical/bus/ac2") > 0)) {
wing_ctl.setValue(1);
} else {
wing_ctl.setValue(0);
}
# landL
if (landlSw.getValue() == 1 and getprop("/systems/electrical/bus/ac1") > 0) {
landL.setValue(1);
} else {
landL.setValue(0);
}
if (landrSw.getValue() == 1 and getprop("/systems/electrical/bus/ac2") > 0) {
landR.setValue(1);
} else {
landR.setValue(0);
}
2018-11-19 14:18:06 +00:00
# signs
if (getprop("/systems/pressurization/cabinalt-norm") > 11300) {
setprop("/controls/lighting/seatbelt-sign", 1);
setprop("/controls/lighting/no-smoking-sign", 1);
} else {
if (getprop("controls/switches/seatbelt-sign") == 1) {
if (getprop("/controls/lighting/seatbelt-sign") == 0) {
setprop("/controls/lighting/seatbelt-sign", 1);
}
} elsif (getprop("controls/switches/seatbelt-sign") == 0) {
if (getprop("/controls/lighting/seatbelt-sign") == 1) {
setprop("/controls/lighting/seatbelt-sign", 0);
}
}
if (getprop("controls/switches/no-smoking-sign") == 1) {
if (getprop("/controls/lighting/no-smoking-sign") == 0) {
setprop("/controls/lighting/no-smoking-sign", 1);
}
2018-11-19 15:13:52 +00:00
} elsif (getprop("controls/switches/no-smoking-sign") == 0.5 and getprop("gear/gear[0]/position-norm") != 0) { # todo: should be when uplocks not engaged
2018-11-19 14:18:06 +00:00
if (getprop("/controls/lighting/no-smoking-sign") == 0) {
setprop("/controls/lighting/no-smoking-sign", 1);
}
} else {
setprop("/controls/lighting/no-smoking-sign", 0); # sign stays on in cabin but sound still occurs
}
}
2018-12-08 17:38:14 +00:00
if (getprop("controls/lighting/landing-lights[1]") >= 0.5) {
setprop("/fdm/jsbsim/rubbish/landL", 1);
} else {
setprop("/fdm/jsbsim/rubbish/landL", 0);
}
if (getprop("controls/lighting/landing-lights[2]") >= 0.5) {
setprop("/fdm/jsbsim/rubbish/landR", 1);
} else {
setprop("/fdm/jsbsim/rubbish/landR", 0);
}
2017-08-04 17:59:05 +00:00
});
2017-09-21 16:52:19 +00:00
2017-10-03 19:08:31 +00:00
var lTray = func {
var lTrayCMD = getprop("/controls/tray/lefttrayext");
2017-10-03 19:39:57 +00:00
if (lTrayCMD < 0.5) {
interpolate("/controls/tray/lefttrayext", 0.5, 0.5);
} else if (lTrayCMD == 0.5) {
interpolate("/controls/tray/lefttrayext", 1.0, 0.5);
2017-10-03 19:08:31 +00:00
} else {
2017-10-03 19:39:57 +00:00
interpolate("/controls/tray/lefttrayext", 0.0, 1.0);
2017-10-03 19:08:31 +00:00
}
}
var rTray = func {
var rTrayCMD = getprop("/controls/tray/righttrayext");
2017-10-03 19:39:57 +00:00
if (rTrayCMD < 0.5) {
interpolate("/controls/tray/righttrayext", 0.5, 0.5);
} else if (rTrayCMD == 0.5) {
interpolate("/controls/tray/righttrayext", 1.0, 0.5);
2017-10-03 19:08:31 +00:00
} else {
2017-10-03 19:39:57 +00:00
interpolate("/controls/tray/righttrayext", 0.0, 1.0);
2017-10-03 19:08:31 +00:00
}
}
2017-10-23 21:44:21 +00:00
var l1Pedal = func {
var lPedalCMD = getprop("/controls/footrest-cpt[0]");
if (lPedalCMD < 1.0) {
interpolate("/controls/footrest-cpt[0]", 1.0, 0.5);
} else {
interpolate("/controls/footrest-cpt[0]", 0.0, 0.5);
}
}
var l2Pedal = func {
var l2PedalCMD = getprop("/controls/footrest-cpt[1]");
if (l2PedalCMD < 1.0) {
interpolate("/controls/footrest-cpt[1]", 1.0, 0.5);
} else {
interpolate("/controls/footrest-cpt[1]", 0.0, 0.5);
}
}
var r1Pedal = func {
var rPedalCMD = getprop("/controls/footrest-fo[0]");
if (rPedalCMD < 1.0) {
interpolate("/controls/footrest-fo[0]", 1.0, 0.5);
} else {
interpolate("/controls/footrest-fo[0]", 0.0, 0.5);
}
}
var r2Pedal = func {
var r2PedalCMD = getprop("/controls/footrest-fo[1]");
if (r2PedalCMD < 1.0) {
interpolate("/controls/footrest-fo[1]", 1.0, 0.5);
} else {
interpolate("/controls/footrest-fo[1]", 0.0, 0.5);
}
}
2017-10-03 19:39:57 +00:00
2017-12-17 19:18:06 +00:00
if (getprop("/controls/flight/auto-coordination") == 1) {
setprop("/controls/flight/auto-coordination", 0);
2017-12-24 17:34:22 +00:00
setprop("/controls/flight/aileron-drives-tiller", 1);
} else {
setprop("/controls/flight/aileron-drives-tiller", 0);
2017-12-17 19:18:06 +00:00
}
2018-09-14 18:51:25 +00:00
setprop("/systems/acconfig/libraries-loaded", 1);