this module is meant for pure startup code. It shall not contain any library
code that is called from outside. It will be removed from the global namespace once it has done its job. For now it only selects a proper runway for wind directions reported by METAR, but only, of course, if an airport was chosen, but no runway and no heading, and if the aircraft is actually on ground.
This commit is contained in:
parent
175911c180
commit
693bebcd43
1 changed files with 33 additions and 0 deletions
33
Nasal/startup.nas
Normal file
33
Nasal/startup.nas
Normal file
|
@ -0,0 +1,33 @@
|
|||
var metar_runway = func {
|
||||
# select runway according to wind direction reported by METAR
|
||||
|
||||
if (!getprop("/environment/metar/real-metar"))
|
||||
return printlog("info", "metar-rwy: no live weather");
|
||||
if (getprop("/environment/metar/base-wind-speed-kt") < 1)
|
||||
return; # windspeed pointless for runway choice
|
||||
if (!getprop("/sim/startup/options/airport"))
|
||||
return printlog("info", "metar-rwy: no airport requested");
|
||||
if (getprop("/sim/startup/options/runway"))
|
||||
return printlog("info", "metar-rwy: won't override explicit runway");
|
||||
if (getprop("/sim/startup/options/heading-deg") < 9990.0)
|
||||
return printlog("info", "metar-rwy: won't override explicit heading");
|
||||
if (!getprop("/sim/presets/onground"))
|
||||
return printlog("info", "metar-rwy: we aren't on ground");
|
||||
|
||||
var from = getprop("/environment/metar/base-wind-range-from");
|
||||
var to = getprop("/environment/metar/base-wind-range-to");
|
||||
var wind_from = (from + to) * 0.5;
|
||||
|
||||
printlog("info", "metar-rwy: setting new target heading ", wind_from);
|
||||
setprop("/sim/presets/heading-deg", wind_from);
|
||||
setprop("/sim/presets/longitude-deg", -9999);
|
||||
setprop("/sim/presets/latitude-deg", -9999);
|
||||
fgcommand("presets-commit");
|
||||
printlog("info", "metar-rwy: selected runway: ", getprop("/sim/atc/runway"));
|
||||
}
|
||||
|
||||
|
||||
_setlistener("/sim/signals/nasal-dir-initialized", func {
|
||||
metar_runway();
|
||||
delete(globals, "startup");
|
||||
});
|
Loading…
Reference in a new issue