Howto:Add new fgcommands to FlightGear: Difference between revisions

Jump to navigation Jump to search
m
Line 83: Line 83:


<syntaxhighlight lang="php">
<syntaxhighlight lang="php">
  fgcommand("null", rops.Node.new( {"filename": "stars.jpeg"} ) );
  fgcommand("null", props.Node.new( {"filename": "stars.jpeg"} ) );
</syntaxhighlight>
</syntaxhighlight>


 
In general, using a temporary property tree object is preferable and recommended if you don't need to access the data in the global property tree otherwise.


So, what the C++ code is doing once it is called, is getting the arguments out of the property argument, see [http://gitorious.org/fg/flightgear/blobs/next/src/Main/fg_commands.cxx#line1183 line 1183]:
So, what the C++ code is doing once it is called, is getting the arguments out of the property argument, see [http://gitorious.org/fg/flightgear/blobs/next/src/Main/fg_commands.cxx#line1183 line 1183]:
Line 106: Line 106:
* const char * getStringValue () const: Get a string value for this node.  
* const char * getStringValue () const: Get a string value for this node.  


However, before actually trying to read in an argument, it is better to first check if he node is actually available, too:
However, before actually trying to read in an argument, it is better to first check if the node is actually available, too:


<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">

Navigation menu