Hi Gijs,
here is a better solution:
there is a property "valid" in /environment/metar which fires the
listeners. The property is true if and only if there given metar string
is a valid metar report. The valid property will be written true every
time a new metar string is written (and parsed).
So, listen to /environment/metar/valid and if that property is true,
read the values from /environment/metar you are interested in. If it is
false, ignore those valid as their state is undefined.
HTH
Torsten
Hi,
I've been trying to make the shader's snow line listen to METAR. METAR
reports whether an airport
has snow on the ground or not. Apparently FlightGear was already set
up to read this and put it in a
property: /environment/metar/snow-cover.
I wrote a Nasal script, everything works fine, but I stumble accross a
problem with my listener. For
some reason the snow-cover property seems to be tied and therefore it
always reports "nil" to a
listener (AndersG said so, I got no idea what that means).
Would it be possible to untie the prop? Or is there a better solution?
You can find the script below.
Cheers,
Gijs
var snowLineDefault = 3200;
var checkSnow = func {
var snowCover = getprop("/environment/metar/snow-cover");
var stationElev =
getprop("/environment/metar/station-elevation-ft") * globals.FT2M;
var snowLine = getprop("/environment/snow-level-m");
# no data available, fall back to default
if (snowCover == nil){
snowLine = snowLineDefault;
}
# no snow at station's altitude, plausiblyhigher
if (snowCover == 0){
if (stationElev < snowLineDefault) { snowLine = snowLineDefault; }
if (stationElev >= snowLineDefault) { snowLine = stationElev; }
}
# snow at station's altitude, plausibly lower
if (snowCover == 1){
snowLine = stationElev;
}
setprop("/environment/snow-level-m",snowLine);
};
_setlistener("/sim/signals/fdm-initialized", func {
_setlistener("/environment/metar/snow-cover", checkSnow);
});
------------------------------------------------------------------------------
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of
discussion for anyone considering optimizing the pricing and packaging model
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel
------------------------------------------------------------------------------
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of
discussion for anyone considering optimizing the pricing and packaging model
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel