Save properties between sessions

From FlightGear wiki
Revision as of 21:10, 29 November 2015 by Necolatis (talk | contribs) (Created page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

You can make properties persistent between flying sessions on the same Aircraft, using the aircraft.data system.

Nasal example

So I want the properties /sim/bla1 and /sim/bla2 to be persistent.

I run this nasal code once:

aircraft.data.add("sim/bla1", "sim/bla2");
aircraft.data.save();

Then the properties are saved when that code is run, and also at every reinit and exit.

If I want it to be saved every 30 seconds in addition to the above, then I change the last line to:

aircraft.data.save(0.5);

Now to make sure the properties are also read at the startup I will modify the xml declarations of the properties to read something like this:

<bla1 userarchive="y" type="bool">true</bla1>
<bla2 userarchive="y" type="int">56</bla2>