Nasal: clean up setlistener() code.

parent 5cdd3839
......@@ -571,14 +571,7 @@ setlistener("/sim/signals/fdm-initialized", func(p) {
if(p.getValue() == 0){
return;
}
_control = getprop("/sim/crew/copilot/control");
_callouts = getprop("/sim/crew/copilot/callouts");
_Htransition = getprop("/sim/crew/orders/transition-m");
_set_qnh = getprop("/sim/crew/orders/set-qnh");
_set_qnh_mmhg = getprop("/sim/crew/orders/altimeter-mmHg");
_QNH = _set_qnh_mmhg;
_deploy_parachute = getprop("/sim/crew/orders/landing/parachute");
_deploy_reversers = getprop("/sim/crew/orders/landing/reversers");
_gearpos = getprop("/fdm/jsbsim/gear/gear-pos-norm");
_canardpos = getprop("/fdm/jsbsim/fcs/canard/pos-norm");
var overlay = getprop("/nasal/overlay/name") or "";
......@@ -601,28 +594,28 @@ setlistener("/sim/signals/fdm-initialized", func(p) {
setlistener("/sim/crew/copilot/control", func(p) {
_control = p.getValue();
});
}, 1, 0);
setlistener("/sim/crew/copilot/callouts", func(p) {
_callouts = p.getValue();
});
}, 1, 0);
setlistener("/sim/crew/orders/transition-m", func(p) {
_Htransition = p.getValue();
});
}, 1, 0);
setlistener("/sim/crew/orders/set-qnh", func(p) {
_set_qnh = p.getValue();
});
}, 1, 0);
setlistener("/sim/crew/orders/altimeter-mmHg", func(p) {
_set_qnh_mmhg = p.getValue();
});
}, 1, 0);
setlistener("/sim/crew/orders/landing/parachute", func(p) {
_deploy_parachute = p.getValue();
});
}, 1, 0);
setlistener("/sim/crew/orders/landing/reversers", func(p) {
_deploy_reversers = p.getValue();
});
}, 1, 0);
......@@ -221,9 +221,6 @@ setlistener("/sim/signals/fdm-initialized", func(p) {
if(p.getValue() == 0){
return;
}
_control = getprop("/sim/crew/engineer/control");
_callouts = getprop("/sim/crew/engineer/callouts");
_wet_runway = getprop("/sim/crew/orders/takeoff/wet-runway");
var overlay = getprop("/nasal/overlay/name") or "";
if((overlay == "subsonic") or (overlay == "cruise") or (overlay == "approach")){
_ready = 1;
......@@ -235,13 +232,13 @@ setlistener("/sim/signals/fdm-initialized", func(p) {
setlistener("/sim/crew/engineer/control", func(p) {
_control = p.getValue();
});
}, 1, 0);
setlistener("/sim/crew/engineer/callouts", func(p) {
_callouts = p.getValue();
});
}, 1, 0);
setlistener("/sim/crew/orders/takeoff/wet-runway", func(p) {
_wet_runway = p.getValue();
CalcTakeoff();
});
}, 1, 0);
......@@ -97,7 +97,7 @@ setlistener("/sim/statistics/run-sec", func(p){
var minutes = int(math.mod(seconds/60, 60));
seconds = int(math.mod(seconds, 60));
setprop("/sim/statistics/run-string", sprintf("%0u:%02u:%02u", hours, minutes, seconds));
});
}, 1, 0);
setlistener("/sim/statistics/flight-sec", func(p){
seconds = p.getValue();
......@@ -108,4 +108,4 @@ setlistener("/sim/statistics/flight-sec", func(p){
var minutes = int(math.mod(seconds/60, 60));
seconds = int(math.mod(seconds, 60));
setprop("/sim/statistics/flight-string", sprintf("%0u:%02u:%02u", hours, minutes, seconds));
});
}, 1, 0);
......@@ -24,7 +24,6 @@ var valid = 0;
var GS_elev_valid = 0;
var LOC_elev_valid = 0;
var enable = 0;
var code = nil;
var channel = 0;
......@@ -228,25 +227,11 @@ var stop = func() {
}
setlistener("/sim/signals/fdm-initialized", func(p) {
if(p.getValue() == 0){
return;
}
stop();
if(getprop("/sim/mobilePRMG/enabled")){
start();
}
});
setlistener("/sim/mobilePRMG/enabled", func(p) {
var enable_new = p.getValue();
if(enable_new > enable){
var enable = p.getValue();
if(enable){
start();
enable = enable_new;
}else if(enable_new < enable){
}else{
stop();
enable = enable_new;
}
});
}, 1, 0);
......@@ -8,8 +8,6 @@ var latitude = nil;
var longitude = nil;
var elevation = 0.0;
var enable = 0;
# @brief Return maximum range in km.
# @param dH height of the aircraft wrt navaid in m.
......@@ -94,33 +92,19 @@ var stop = func() {
}
setlistener("/sim/signals/fdm-initialized", func(p) {
if(p.getValue() == 0){
return;
}
stop();
if(getprop("/sim/mobileRSBN/enabled")){
start();
}
});
setlistener("/sim/mobileRSBN/enabled", func(p) {
var enable_new = p.getValue();
if(enable_new > enable){
var enable = p.getValue();
if(enable){
start();
enable = enable_new;
}else if(enable_new < enable){
}else{
stop();
enable = enable_new;
}
});
}, 1, 0);
setlistener("/sim/mobileRSBN/latitude-deg", func(p) {
latitude = p.getValue();
});
}, 1, 0);
setlistener("/sim/mobileRSBN/longitude-deg", func(p) {
longitude = p.getValue();
});
}, 1, 0);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment