Properties persistent between sessions

From FlightGear wiki
Jump to navigation Jump to search

Sometimes you would want to have some properties persistent between sessions. It could for example be to save the state of a dialogue or to have an aircraft start up in the same state as you left it.

Preferences and GUI

To make preferences and GUI properties persistent between FlightGear sessions, use the userarchive attribute:

 <?xml version="1.0" encoding="UTF-8"?>
  <foo userarchive="y">Hello</foo> 


To make aircraft properties persistent between FlightGear sessions, add this to the aircrafts -set.xml file:

  <!-- ... -->


Another way to do this if you are more into Nasal than XML would be to instead add this to the aircrafts -set.xml file:

  <!-- ... -->


And yet another way to do this entirely in Nasal is:

Run this nasal code once:"sim/bla1", "sim/bla2");;

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

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

Now to make sure the properties are also read at the startup, 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>

Related content

Wiki articles

Mailing list threads

Source code