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, plausibly higher
    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

Reply via email to