Bindings: Difference between revisions

Jump to navigation Jump to search
661 bytes added ,  27 October 2015
Some more cleanup
(Begin cleanup)
(Some more cleanup)
Line 11: Line 11:


== Commands ==
== Commands ==
Below are a number of useful commands. See for the complete list, see {{flightgear file|src/Main/fg_commands.cxx|l=1425}}.  
Below are a number of useful commands, some also with their equivalent Nasal call. For the complete list, see {{flightgear file|src/Main/fg_commands.cxx|l=1425}}.  


To learn more about adding your own custom fgcommands to the source code, see [[Howto:Add new fgcommands to FlightGear]]
To learn more about adding your own custom fgcommands to the source code, see [[Howto:Add new fgcommands to FlightGear]].


=== dialog-close ===
=== dialog-close ===
Line 21: Line 21:
   <command>dialog-close</command>
   <command>dialog-close</command>
</binding>
</binding>
</syntaxhighlight>
<syntaxhighlight lang="nasal">
fgcommand("dialog-close");
</syntaxhighlight>
</syntaxhighlight>


=== dialog-show ===
=== dialog-show ===
Shows a dialog, which should be present in <tt>''[[$FG_ROOT]]/gui/dialogs''</tt>. Starting with FlightGear 2.7, dialog files located in <tt>''<aircraft directory>/gui/dialogs''</tt> are also loaded. This should be used for dialogs specific to a certain aircraft.
Shows a dialog, which should be present in <tt>''[[$FG_ROOT]]/gui/dialogs''</tt>. In addition, from FlightGear 2.8, dialog files located in <tt>''<aircraft directory>/gui/dialogs''</tt> are also loaded. This should be used for dialogs specific to a certain aircraft.
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<binding>
<binding>
Line 31: Line 34:
</binding>
</binding>
</syntaxhighlight>
</syntaxhighlight>
* '''dialog-name:''' the name of the dialog, as designated in its .xml file.
<syntaxhighlight lang="nasal">
fgcommand("dialog-show", props.Node.new({"dialog-name": "location-in-air"}));
</syntaxhighlight>
 
; dialog-name : The name of the dialog, as designated in its XML file.


=== nasal ===
=== nasal ===
Line 41: Line 48:
</binding>
</binding>
</syntaxhighlight>
</syntaxhighlight>
; script : The Nasal script to execute.
: {{inote|Make sure that the script does not conflict with the {{wikipedia|List of XML and HTML character entity references#Predefined entities in XML|predefined XML entities}}. If it does, you can either put it in a {{wikipedia|CDATA|CDATA section}} or use a non-interpreted version (e.g., <code>&amp;gt;</code> in place of <code>></code>).}}
The {{func link|cmdarg}} function is often useful in these situations to extract offset values passed to the binding. It returns the specific <tt>&lt;binding&gt;</tt> node, which contains a <tt>&lt;setting&gt;</tt> node at runtime if used in a joystick axis that represents the value of that axis.
The {{func link|cmdarg}} function is often useful in these situations to extract offset values passed to the binding. It returns the specific <tt>&lt;binding&gt;</tt> node, which contains a <tt>&lt;setting&gt;</tt> node at runtime if used in a joystick axis that represents the value of that axis.


In joysticks and keyboard keys the script is run in a specific namespace; please refer to the documentation for what the namespace is.
In joysticks and keyboard keys, the script is run in a specific namespace; please see [[Howto:Understand Namespaces and Methods]] for more information on namespaces.


=== property-adjust ===
=== property-adjust ===

Navigation menu