• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

MSFS20 Reading a setting in aircraft.cfg file from within JS

Back to saving a gauge's parameters.

I can now see how a WASM gauge can save parameters to be persistent between MSFS sessions. (although I don't see any examples, or anyone doing this yet)
So is there a way that, using a WASM "dummy gauge" for a JS gauge to use that dummy WASM gauge to save it parameters ? maybe by using : L:Vars

I am sitting here, in a very simplistic JS gauge Modding environment, trying to achieve saving some of my JS gauge setting between sessions.
Do I stand any chance of doing this, without a year+ of learning how to do complex programming specific to MSFS, that seem to be beyond many 3rd party developers at the moment.

I just want to be able to have a function in my JS gauge, that saves a few Options, that can be changed in the Gauge ( ie North up/ Heading UP )
 
I can now see how a WASM gauge can save parameters to be persistent between MSFS sessions. (although I don't see any examples, or anyone doing this yet)
So is there a way that, using a WASM "dummy gauge" for a JS gauge to use that dummy WASM gauge to save it parameters ? maybe by using : L:Vars
Geoff_D if you made progress with this basic requirement could you share it here?

I got so close (but no cigar) trying the standard JS method of persisting data, i.e. window.localStorage.setItem('myvar','my stored string') - followed by window.localStorage.getItem('myvar') This actually works (!) within the gauge but the localStorage doesn't survive an MSFS restart.

A slightly bizarre-sounding option for low-frequency data would be to use the standard XMLHttpRequest() with an external web server - e.g. a windows binary on your PC would exist purely to serve a single URL and *it* would persist the data between requests i.e. http://localhost/msfs_store?var=mycar&value=myvalue. It's a pain needing an external binary though.

The WASM solution sounds the most promising (I didn't know it could *write* to the VFS - is there an example somewhere?) - a simple WASM gauge purely to bridge to the the filesystem would be a great utility that could be loaded with the aircraft.
 
Last edited:
Local storage through HTML/JS gauges can easily be accomplished
..when you know how... Many thanks, I followed your link and had it up and running immediately. I'm guessing it is literally window.localStorage as is seems the stored value is required to be a string.

I was completely unaware in your html/JS gauge code you can:

Include.addScript("/JS/dataStorage.js");

And then in your gauge class you can persist string values with:

SetStoredData("my_unique_var_name", "string value to save");

And get the data back with:

var my_stored_value = GetStoredData("my_unique_var_name");

Worryingly I never even knew "JS/dataStorage.js" existed and still haven't found it in the MSFS install.
 
Worryingly I never even knew "JS/dataStorage.js" existed and still haven't found it in the MSFS install.
It's in the fs-base-ui package which ships in the core game install. If you're on steam this is in your steamapps folder, if you're running the MS Store msixvc packaged build you'd have to use uwpdumper to get at the files.
 
I have something unexpected here - please can I confirm the key-value pair should PERSIST between sim sessions ?? I'm praying I didn't misunderstand the answer and the storage is temporary.

I have successfully WRITTEN a string to localStorage with SetStoredData("B21_test_key","B21");

And can successfully read that data from a different HTML/JS gauge with GetStoredData("B21_test_key") (returns "B21")

But if I quit MSFS, comment out the SetStoredData("B21_test_key","B21");, and restart the sim and reload my test aircraft, the GetStoredData("B21_test_key") does NOT return the string.

If the data is definitely persisted, then don't worry about debugging my code, but I'm really keen to know if HTML/JS has a persistent key/value store or not.
 
Thanks very much for this exceptionally useful info.

Heads up: My testing suggests SetStoredData("key","value") is stored in memory until you exit the sim, and persisted to the filesystem on exit. If you exit the sim by clicking the [x] in the top-right corner of the MSFS main window, or exit via Alt-F4, then MSFS exits without persisting the SetStoredData data.

It's possible MSFS could have intended an asynchronous write to the file system some time later in the session, and I didn't wait long enough (a minute?) before quitting.
 
Back
Top