Hello, it would be very helpful to have a LVAR variable to be able to turn
live weather on or off. I would love to assign a physical switch (home cockpit
user) to turn live weather on or off (without using the screen
Thanks Okan Sacli
Hello, it would be very helpful to have a LVAR variable to be able to turn
live weather on or off. I would love to assign a physical switch (home cockpit
user) to turn live weather on or off (without using the screen
Thanks Okan Sacli
Yeah at the very least I would like to know if its on or off.
Rob Murdoch
PMDG
Weāre really not setting the bar very high here⦠Iād like an API where I can retrieve the current loaded weather data plus a ālive weatherā flag. The parameters for the weather are pretty basic (wind layers, cloud layers, temp/pressure) so reading that in a single query should be relatively simple.
Knowing whether live weather is on or off would be very useful for avionics developers, as then we can know whether to apply cold weather altimetry corrections based on temperature as some real systems do, or not. Applying corrections with offline weather would be counter-productive, as it does not seem to actually alter the lapse rate with temperature.
const wx_listener = RegisterViewListener("JS_LISTENER_WEATHER", () => {});
wx_listener.on('UpdatePreset', (weather) => {
const is_live = weather.index == 0;
console.log(weather, is_live);
// You're welcome!
});
wx_listener.on('SetWeatherList', (weather_presets) => {
// If you want the list of wx presets.
console.log(weather_presets);
});
wx_listener.trigger('ASK_WEATHER_LIST');
To noteā¦
wx_listener.unregister()) and re-register the ViewListener if you want to get fresh data periodically. The sim doesnāt trigger UpdatePreset when the preset changes despite what the event name infers.html_ui/js/services/weather.js to get the full list of capabilities. Itās what the weather panel uses to control weather settings. Yes you can also inject custom weather that way To set weather to live:
wx_listener.trigger('CUSTOM_WEATHER_PRESET_CHANGED', 0); // Use the ID of the desired preset. 0 = Live
Keven Menard
//42
Keven this is awesome - massively appreciated. I looked at weather.js as soon as I discovered it but on my own I totally failed to get it to give me the ācurrent preset infoā. Your code worked straight out of the box.
For multiplayer gliding in MSFS the ability to signature the loaded weather is really quite important, so thanks again.
Hi Keven !
I really donāt know anything about code, but, although I have live weather on, the Sun desperately shines everywhere ! (Iām playing on PC) Could your code line help me ? But what should I do with it ?
Thanx for your help !
It looks to me like this might no longer be working.
Previously that UpdatePreset would fire ONCE given this code in the gauge so that would give you the āweatherā layers data in the callback. As previously reported the callaback otherwise was not called if the preset changed, so it required polling of the RegisterViewListener(āJS_LISTENER_WEATHERā,ā¦) to keep on top of what weather was currently loaded, but the limited functionality still meant the Wx preset data could be read.
As far as I can tell the callback is now NEVER being called & I canāt see any other way of getting the data from the currently loaded WPR preset file.
Anyone have any clues? It could be just me but certainly my prior āworkingā code is non-functional and I canāt get the clean example from @runshotgun to work in the Coherent Console as before.
In 2020 you only (and automatically) got the data right after registering the listener, in 2024 you have to ask for that data manually.
The cool thing about this change is you can get refreshed data for the current preset whenever you need!
askUpdatePreset()
{
this.trigger("ASK_UPDATE_PRESET");
}
With the code sample, it would be wx_listener.trigger("ASK_UPDATE_PRESET");
I remain in awe of your investigative skillsā¦
if you can help a man learn to fish, how did you find that āASK_UPDATE_PRESETā trigger value? I looked through fs-base-ui .. Weather.js and the sdk docs JS_LISTENER_WEATHER with the idea something like that might be needed (I found āADD_WEATHER_PRESETā, close but no cigar).
many thanks
edit - before I go off to check it, do you know if the same āASKā method works in 2020 & 2024 ? thanks again.
The ASK_UPDATE_PRESET is used in lib.bundle.js in the WeatherListener class.
There are multiple ways to go about finding those⦠some require custom tools; some just require patience. In this case we already have something to work with (the 2020 code) so it was a matter of searching for known code in the default Weather Panel of the new sim and looking around it for new functions.
It does not. The only way is to Unregister and Re-register the listener to get it again.
thanks very much indeed - these prompt answers really help a lot. (Small addendum in case it helps anyone: maybe 2024 fs-base-ui .. Weather.js is no longer used as that code doesnāt match the same WeatherListener class bundled inside fs-base-ui/html_ui/Global/lib.bundle.js)