- Code: Select all
# Create initial announced variables at startup of the sim
V1 = 1.0;
VR = 2.0;
V2 = 3.0;
# The actual function
setlistener("sim/signals/fdm-initialized", func
{
settimer(vspeeds, 1);
});
var vspeeds = func {
# Create/populate variables at each function cycle
# Retrieve total aircraft weight and convert to kg.
WT = getprop("yasim/gross-weight-lbs")*0.0004535;
flaps = getprop("controls/flight/flaps");
# Calculate V-speeds with flaps 10
if (flaps == 0.2) {
V1 = (0.3*(WT-200.0))+100;
VR = (0.3*(WT-200.0))+115;
V2 = (0.3*(WT-200.0))+135;
}
# Calculate V-speeds with flaps 20
elsif (flaps == 0.4) {
V1 = (0.3*(WT-200.0))+95;
VR = (0.3*(WT-200.0))+110;
V2 = (0.3*(WT-200.0))+130;
}
# Calculate V-speeds with flaps 30
elsif (flaps == 0.6) {
V1 = (0.3*(WT-200.0))+90;
VR = (0.3*(WT-200.0))+105;
V2 = (0.3*(WT-200.0))+125;
}
# Calculate V-speeds with flaps 40
elsif (flaps == 0.8) {
V1 = (0.3*(WT-200.0))+85;
VR = (0.3*(WT-200.0))+100;
V2 = (0.3*(WT-200.0))+120;
}
# Export the calculated V-speeds to the property-tree, for further use
setprop("/instrumentation/adc/reference/V1",V1);
setprop("/instrumentation/adc/reference/Vr",VR);
setprop("/instrumentation/adc/reference/V2",V2);
# Repeat the function each second
# settimer(vspeeds, 1);
}
# Only start the function when the FDM is initialized, to prevent the problem of not-yet-created properties.
# setlistener("/sim/signals/fdm-initialized", vspeeds);
I set the initial variables to 1, 2, and 3 for debugging purposes and they stayed the same in the property browser so I know that the function is not running, but I don't get why. There are no parsing errors or anything, and I have called the function in my aircraft set.xml under the nasal tags