Library globals

Class globals . aircraft . data

View source

data
==============================================================================
class that loads and saves properties to aircraft-specific data files in
~/.fgfs/aircraft-data/ (Unix) or %APPDATA%\flightgear.org\aircraft-data\.
There's no public constructor, as the only needed instance gets created
by the system.

SYNOPSIS:
data.add(<properties>);
data.save([<interval>])

properties  ... about any combination of property nodes (props.Node)
or path name strings, or lists or hashes of them,
lists of lists of them, etc.
interval    ... save in <interval> minutes intervals, or only once
if 'nil' or empty (and again at reinit/exit)

SIGNALS:
/sim/signals/save   ... set to 'true' right before saving. Can be used
to update values that are to be saved

EXAMPLE:
var p = props.globals.getNode("/sim/model", 1);
var vec = [p, p];
var hash = {"foo": p, "bar": p};

# add properties
aircraft.data.add("/sim/fg-root", p, "/sim/fg-home");
aircraft.data.add(p, vec, hash, "/sim/fg-root");

# now save only once (and at exit/reinit, which is automatically done)
aircraft.data.save();

# or save now and every 30 sec (and at exit/reinit)
aircraft.data.save(0.5);

Functions

add

init

load

save