Properties persistent between sessions
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
<?xml version="1.0" encoding="UTF-8"?> <PropertyList> <foo userarchive="y">Hello</foo> </PropertyList>
To make aircraft properties persistent between FlightGear sessions, add this to the aircrafts -set.xml file:
<sim> <!-- ... --> <aircraft-data> <path>/controls/flight/flaps</path> <path>/controls/lighting/nav</path> </aircraft-data> </sim>
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:
<nasal> <!-- ... --> <MyModule> <script><![CDATA[ aircraft.data.add( "/controls/flight/flaps", "/controls/lighting/nav", ); ]]></script> </MyModule> </nasal>
And yet another way to do this entirely in Nasal is:
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 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>
Mailing list threads
- [Flightgear-devel] Property Tree Question: How to save an aircraft specific property between sessions..
- fgdata/Nasal/aircraft.nas – See the