395
edits
Philosopher (talk | contribs) m (→getprop()) |
|||
Line 72: | Line 72: | ||
=== <tt>getprop()</tt> === | === <tt>getprop()</tt> === | ||
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 the same as: | |||
<syntaxhighlight lang="nasal"> | <syntaxhighlight lang="nasal"> | ||
getprop("canvas/by-index/texture[1]/name"); | getprop("canvas/by-index/texture[1]/name"); | ||
</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> | ||
edits