Optimize light loops by using props.global and removing last lighting setlistener
This commit is contained in:
parent
457a8075b0
commit
d6764c6a68
1 changed files with 38 additions and 37 deletions
|
@ -50,24 +50,8 @@ var right_turnoff_light = props.globals.getNode("/controls/lighting/rightturnoff
|
||||||
var settingT = getprop("/controls/lighting/taxi-light-switch");
|
var settingT = getprop("/controls/lighting/taxi-light-switch");
|
||||||
var settingTurnoff = getprop("/controls/lighting/turnoff-light-switch");
|
var settingTurnoff = getprop("/controls/lighting/turnoff-light-switch");
|
||||||
var setting = getprop("/controls/lighting/nav-lights-switch");
|
var setting = getprop("/controls/lighting/nav-lights-switch");
|
||||||
|
var landl = getprop("/controls/lighting/landing-lights[1]");
|
||||||
setlistener("controls/lighting/landing-lights[1]", func {
|
var landr = getprop("/controls/lighting/landing-lights[2]");
|
||||||
var landl = getprop("/controls/lighting/landing-lights[1]");
|
|
||||||
if (landl == 1) {
|
|
||||||
setprop("/sim/rendering/als-secondary-lights/use-landing-light", 1);
|
|
||||||
} else {
|
|
||||||
setprop("/sim/rendering/als-secondary-lights/use-landing-light", 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setlistener("controls/lighting/landing-lights[2]", func {
|
|
||||||
var landr = getprop("/controls/lighting/landing-lights[2]");
|
|
||||||
if (landr == 1) {
|
|
||||||
setprop("/sim/rendering/als-secondary-lights/use-alt-landing-light", 1);
|
|
||||||
} else {
|
|
||||||
setprop("/sim/rendering/als-secondary-lights/use-alt-landing-light", 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# Tire Smoke/Rain #
|
# Tire Smoke/Rain #
|
||||||
|
@ -377,17 +361,10 @@ var flaptimer = maketimer(0.5, func {
|
||||||
var lightsLoop = maketimer(0.2, func {
|
var lightsLoop = maketimer(0.2, func {
|
||||||
gear = getprop("/gear/gear[0]/position-norm");
|
gear = getprop("/gear/gear[0]/position-norm");
|
||||||
nose_lights = getprop("/sim/model/lights/nose-lights");
|
nose_lights = getprop("/sim/model/lights/nose-lights");
|
||||||
left_turnoff_light = props.globals.getNode("/controls/lighting/leftturnoff");
|
|
||||||
right_turnoff_light = props.globals.getNode("/controls/lighting/rightturnoff");
|
|
||||||
logo_lights = getprop("/sim/model/lights/logo-lights");
|
|
||||||
nav_lights = props.globals.getNode("/sim/model/lights/nav-lights");
|
|
||||||
wow = getprop("/gear/gear[2]/wow");
|
|
||||||
slats = getprop("/controls/flight/slats");
|
|
||||||
settingT = getprop("/controls/lighting/taxi-light-switch");
|
settingT = getprop("/controls/lighting/taxi-light-switch");
|
||||||
settingTurnoff = getprop("/controls/lighting/turnoff-light-switch");
|
|
||||||
setting = getprop("/controls/lighting/nav-lights-switch");
|
|
||||||
|
|
||||||
# nose lights
|
# nose lights
|
||||||
|
|
||||||
if (settingT == 0.5 and gear > 0.9) {
|
if (settingT == 0.5 and gear > 0.9) {
|
||||||
setprop("/sim/model/lights/nose-lights", 0.85);
|
setprop("/sim/model/lights/nose-lights", 0.85);
|
||||||
} else if (settingT == 1 and gear > 0.9) {
|
} else if (settingT == 1 and gear > 0.9) {
|
||||||
|
@ -397,7 +374,11 @@ var lightsLoop = maketimer(0.2, func {
|
||||||
}
|
}
|
||||||
|
|
||||||
# turnoff lights
|
# turnoff lights
|
||||||
if (settingT == 1 and gear > 0.9) {
|
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");
|
||||||
|
|
||||||
|
if (settingTurnoff == 1 and gear > 0.9) {
|
||||||
left_turnoff_light.setBoolValue(1);
|
left_turnoff_light.setBoolValue(1);
|
||||||
right_turnoff_light.setBoolValue(1);
|
right_turnoff_light.setBoolValue(1);
|
||||||
} else {
|
} else {
|
||||||
|
@ -405,26 +386,46 @@ var lightsLoop = maketimer(0.2, func {
|
||||||
right_turnoff_light.setBoolValue(0);
|
right_turnoff_light.setBoolValue(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
# logo light
|
# logo and navigation lights
|
||||||
if (setting == 0 and logo_lights == 1) {
|
setting = getprop("/controls/lighting/nav-lights-switch");
|
||||||
setprop("/sim/model/lights/logo-lights", 0);
|
nav_lights = props.globals.getNode("/sim/model/lights/nav-lights");
|
||||||
} else if (setting == 1 or setting == 2) {
|
logo_lights = props.globals.getNode("/sim/model/lights/logo-lights");
|
||||||
if (wow) {
|
wow = getprop("/gear/gear[2]/wow");
|
||||||
setprop("/sim/model/lights/logo-lights", 1);
|
slats = getprop("/controls/flight/slats");
|
||||||
} else if (!wow and slats > 0) {
|
|
||||||
setprop("/sim/model/lights/logo-lights", 1);
|
|
||||||
} else {
|
|
||||||
setprop("/sim/model/lights/logo-lights", 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# navigation lights
|
if (setting == 0 and logo_lights == 1) {
|
||||||
|
logo_lights.setBoolValue(0);
|
||||||
|
} else if (setting == 1 or setting == 2) {
|
||||||
|
if ((wow) or (!wow and slats > 0)) {
|
||||||
|
logo_lights.setBoolValue(1);
|
||||||
|
} else {
|
||||||
|
logo_lights.setBoolValue(0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logo_lights.setBoolValue(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (setting == 1 or setting == 2) {
|
if (setting == 1 or setting == 2) {
|
||||||
nav_lights.setBoolValue(1);
|
nav_lights.setBoolValue(1);
|
||||||
} else {
|
} else {
|
||||||
nav_lights.setBoolValue(0);
|
nav_lights.setBoolValue(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# landing lights
|
||||||
|
landl = getprop("/controls/lighting/landing-lights[1]");
|
||||||
|
landr = getprop("/controls/lighting/landing-lights[2]");
|
||||||
|
|
||||||
|
if (landl == 1) {
|
||||||
|
setprop("/sim/rendering/als-secondary-lights/use-landing-light", 1);
|
||||||
|
} else {
|
||||||
|
setprop("/sim/rendering/als-secondary-lights/use-landing-light", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (landr == 1) {
|
||||||
|
setprop("/sim/rendering/als-secondary-lights/use-alt-landing-light", 1);
|
||||||
|
} else {
|
||||||
|
setprop("/sim/rendering/als-secondary-lights/use-alt-landing-light", 0);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var lTray = func {
|
var lTray = func {
|
||||||
|
|
Reference in a new issue