Board index FlightGear Development Weather

Help with controlling weather dialog properties via Nasal

Everything related to weather simulation, visuals should be discussed in the shader subforum.

Help with controlling weather dialog properties via Nasal

Postby gkick » Thu Jul 04, 2019 4:35 pm

Hi,

I have a custom dialog which allows to override wind-settings of both basic and advanced weather, so that one can set arbitary wind headings and speeds
without interpolation up to 10k for practicing takeoffs and landings in head, tail, cross or other wind scenarios.

The screen dump image https://www.dropbox.com/s/pq8lxl37o5gmm ... s.JPG?dl=0 shows three dialogs,

The Set Wind Conditions on the right works fine if the Weather dialog on the left has the radio button on Basic Weather and a check in manual config.
Since I do not know what the default start weather might be, I use the middle dialog Windconfig to switch to Basic Weather and place a check into manual config.
If basic weather is already active the code below just places the check and everything is fine.

Code: Select all
<binding>
         <command>nasal</command>
         <script>
            fgcommand("dialog-show", props.Node.new({ "dialog-name" : "weather" }));
            setprop( "/environment/params/metar-updates-environment", 0 );
            setprop( "/environment/realwx/enabled", 0 ); setprop( "/environment/config/enabled", 1 );
            setprop("/nasal/manual_weather/enabled", "true");
            setprop("/nasal/local_weather/enabled", "false");
            setprop( "/sim/gui/dialogs/metar/mode/global-weather", "1" );
            setprop( "/sim/gui/dialogs/metar/mode/local-weather", "0" );
            setprop( "/sim/gui/dialogs/metar/mode/manual-weather", "1" );
            gui.dialog_update("weather");
            gui.dialog_apply("weather");
            setprop("/devices/status/keyboard/event/key[10]/pressed",1);
            fgcommand("dialog-close", props.Node.new({ "dialog-name" : "weather" }));     
            fgcommand("dialog-close", props.Node.new({ "dialog-name" : "windconfig" }));
            setprop("/systems/mws",1);
         </script>
      </binding>


If the advanced weather is active the code moves the radio button to basic and also places the check and updates relevant properties in
sim/gui/dialogs/metar/mode/global-weather

However the Set Wind dialog will not work because something is missing. If I click the OK or the Apply button in the Weather dialog it does work because the buttons run some functions in the background like update and or refresh

As I go in circles figuring out whats missing I thought of fakeing the ok button press by using the line
setprop("/devices/status/keyboard/event/key[10]/pressed",1);
but that does not produce the desired result nor triggers an error.

The first line of the code opens the weather dialog since the properties of the metar dialog do not exist in the property tree beforehand but can be manipulated after. So the general idea is to only show the Set Wind dialog running the relevant config in the background. Hope the explanation makes some sense

Any ideas will be much appreciated.

Thanks
gkick
 
Posts: 106
Joined: Mon Jan 02, 2017 12:04 am

Re: Help with controlling weather dialog properties via Nasa

Postby Thorsten » Thu Jul 04, 2019 6:10 pm

You do realize that this is quite a hideous hack (which is why it's far from easy to do...)? (There's a translation stage running changing the dialog options into the actual AW config, which is why changing the dialog values doesn't do anything)

AW provides the functionality you want out of the box - so you can simply use it.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Help with controlling weather dialog properties via Nasa

Postby legoboyvdlp » Thu Jul 04, 2019 6:32 pm

Just to add to that - you have made quite a number of posts asking for help on "sub-problems" with nasal - are they all related? If so, maybe you could tell us what the main project is to allow us to help you better.
User avatar
legoboyvdlp
 
Posts: 7981
Joined: Sat Jul 26, 2014 2:28 am
Location: Northern Ireland
Callsign: G-LEGO
Version: next
OS: Windows 10 HP


Return to Weather

Who is online

Users browsing this forum: No registered users and 4 guests