2007-10-10 09:58:22 +00:00
|
|
|
var set_runway_from_metar_wind = func {
|
2010-09-26 15:07:24 +00:00
|
|
|
if (!getprop("/environment/realwx/enabled"))
|
2007-10-07 19:44:58 +00:00
|
|
|
return printlog("info", "metar-rwy: no live weather");
|
2010-09-26 15:07:24 +00:00
|
|
|
if (!getprop("/environment/metar/valid"))
|
|
|
|
return printlog("info", "metar-rwy: no valid metar");
|
2007-10-07 19:44:58 +00:00
|
|
|
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");
|
2007-10-10 09:58:22 +00:00
|
|
|
if (getprop("/environment/metar/base-wind-speed-kt") < 1)
|
|
|
|
return;
|
2007-10-07 19:44:58 +00:00
|
|
|
|
|
|
|
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 {
|
2007-10-10 09:58:22 +00:00
|
|
|
set_runway_from_metar_wind();
|
2007-10-07 19:44:58 +00:00
|
|
|
delete(globals, "startup");
|
|
|
|
});
|