Save properties between sessions: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
(This should be merged into Properties persistent between sessions)
(redirect)
 
Line 1: Line 1:
{{mergeto|Properties persistent between sessions |date=November 2015}}
#redirect [[Properties persistent between sessions]]
 
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:
 
<syntaxhighlight lang="nasal">
aircraft.data.add("sim/bla1", "sim/bla2");
aircraft.data.save();
</syntaxhighlight>
 
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:
 
<syntaxhighlight lang="nasal">
aircraft.data.save(0.5);
</syntaxhighlight>
 
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:
 
<syntaxhighlight lang="xml">
<bla1 userarchive="y" type="bool">true</bla1>
<bla2 userarchive="y" type="int">56</bla2>
</syntaxhighlight>
 
[[Category:FlightGear feature]]

Latest revision as of 21:21, 29 November 2015