List of Nasal extension functions: Difference between revisions

Jump to navigation Jump to search
m
Line 72: Line 72:
=== <tt>getprop()</tt> ===
=== <tt>getprop()</tt> ===


As of FlightGear 3.1, getprop()/setprop() arguments (those that form a path) can now be numeric to specify a index, so:
Returns the node value for a given path, or <tt>nil</tt> if the node doesn't exist or hasn't been initialized to a value yet.  
 
<syntaxhighlight lang="nasal">
getprop(<path> [, <path>, [...]]);
</syntaxhighlight>
 
Several arguments will be added together to produce a path, with numeric arguments specifying indexes (as of FlightGear 3.1), so
<syntaxhighlight lang="nasal">
<syntaxhighlight lang="nasal">
getprop("canvas/by-index", "texture", 1, "name");
getprop("canvas/by-index", "texture", 1, "name");
</syntaxhighlight>
</syntaxhighlight>
: is now the same as:
is the same as:
<syntaxhighlight lang="nasal">
<syntaxhighlight lang="nasal">
getprop("canvas/by-index/texture[1]/name");
getprop("canvas/by-index/texture[1]/name");
</syntaxhighlight>
: (see [https://gitorious.org/fg/flightgear/commit/5eee5e42ae4f5cf56283b3bf5a3be46efc2b51c4 merge request 54] and [https://gitorious.org/fg/flightgear/commit/34ed79e5f88ffdfc5e651a1fe3e639cb8f4d3353 actual commit])
Returns the node value for a given path, or <tt>nil</tt> if the node doesn't exist or hasn't been initialized yet.
<syntaxhighlight lang="nasal">
getprop(<path>);
</syntaxhighlight>
</syntaxhighlight>


Line 92: Line 91:
<syntaxhighlight lang="nasal">
<syntaxhighlight lang="nasal">
print("The frame rate is ", getprop("/sim/frame-rate"), " FPS");
print("The frame rate is ", getprop("/sim/frame-rate"), " FPS");
for (var i=0; i < 10; i += 1) {
    print("View ", i, "'s name is: ", getprop("/sim/view", i, "name"));
}
</syntaxhighlight>
</syntaxhighlight>


395

edits

Navigation menu