2,733
edits
m (→Related content: + Howto:Reassign keyboard bindings) |
Red Leader (talk | contribs) (Begin cleanup) |
||
Line 1: | Line 1: | ||
'''Bindings''' define what happens when a user: | '''Bindings''' define what happens when a user: | ||
* [[Howto: Make a clickable panel | * [[Howto: Make a clickable panel|Clicks an object]] in the [[scenery]] or in an [[aircraft]]. | ||
* | * Presses a key/button on the keyboard or [[joystick]]. | ||
* | * Clicks a [[menu]] item | ||
* | * Interacts with a dialog | ||
You can assign multiple bindings to one object | You can assign multiple bindings to one object, button or key. Bindings may contain [[conditions]] to make them conditionally executed. Each binding must specify a command node with its particular type, see below. | ||
This article gives a small overview of frequently used bindings. Please refer to | This article gives a small overview of frequently used bindings. Please refer to {{readme file|commands}} for additional information and a complete list of available bindings. | ||
All given codes are examples, found on various places in the [[FlightGear]] package. | All given codes are examples, found on various places in the [[FlightGear]] package. | ||
== 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. See | |||
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]] | ||
Line 20: | Line 17: | ||
=== dialog-close === | === dialog-close === | ||
Closes the active dialog. | Closes the active dialog. | ||
<syntaxhighlight> | <syntaxhighlight lang="xml"> | ||
<binding> | <binding> | ||
<command>dialog-close</command> | |||
</binding> | </binding> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== dialog-show === | === dialog-show === | ||
Shows a dialog, which should be present in <tt>[[$ | 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. | ||
<syntaxhighlight> | <syntaxhighlight lang="xml"> | ||
<binding> | <binding> | ||
<command>dialog-show</command> | |||
<dialog-name>location-in-air</dialog-name> | |||
</binding> | </binding> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 38: | Line 35: | ||
=== nasal === | === nasal === | ||
[[Nasal]] is frequently used for complicated systems, because it can execute virtually any function and allows running previously-defined Nasal functions. | [[Nasal]] is frequently used for complicated systems, because it can execute virtually any function and allows running previously-defined Nasal functions. | ||
<syntaxhighlight> | <syntaxhighlight lang="xml"> | ||
<binding> | <binding> | ||
<command>nasal</command> | |||
<script>b777.afds.input(0,1);</script> | |||
</binding> | </binding> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
The | The {{func link|cmdarg}} function is often useful in these situations to extract offset values passed to the binding. It returns the specific <tt><binding></tt> node, which contains a <tt><setting></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 refer to the documentation for what the namespace is. | ||
Line 50: | Line 47: | ||
=== property-adjust === | === property-adjust === | ||
Increases or decreases a property's value with a given step. Maximum and minimum values are optional. | Increases or decreases a property's value with a given step. Maximum and minimum values are optional. | ||
<syntaxhighlight> | <syntaxhighlight lang="xml"> | ||
<binding> | <binding> | ||
<command>property-adjust</command> | |||
<property>/autopilot/settings/heading-bug-deg</property> | |||
<step>1</step> <!-- will add 1 to /autopilot/settings/heading-bug-deg whenever this binding is called --> | |||
<min>000</min> <!-- the property will never be allowed to go below 0 --> | |||
<max>360</max> <!-- ...or above 360 --> | |||
<wrap>true</wrap> <!-- when we hit 361, wrap back to 0 and vice-versa --> | |||
</binding> | </binding> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 63: | Line 60: | ||
=== property-assign === | === property-assign === | ||
One of the most important commands. It sets a property to a predefined value. | One of the most important commands. It sets a property to a predefined value. | ||
<syntaxhighlight> | <syntaxhighlight lang="xml"> | ||
<binding> | <binding> | ||
<command>property-assign</command> | |||
<property>/autopilot/settings/target-speed-kt</property> | |||
<value>0</value> | |||
</binding> | </binding> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 73: | Line 70: | ||
=== property-cycle === | === property-cycle === | ||
Cycles between a list of values and assigns one to a property. The value-list can vary in length. If the current value is "value1", it will change to "value2"; if it is "value2", it will change to "value3", and so on, wrapping around the end. If the current value is not in the list, it will jump to the first one. | Cycles between a list of values and assigns one to a property. The value-list can vary in length. If the current value is "value1", it will change to "value2"; if it is "value2", it will change to "value3", and so on, wrapping around the end. If the current value is not in the list, it will jump to the first one. | ||
<syntaxhighlight> | <syntaxhighlight lang="xml"> | ||
<binding> | <binding> | ||
<command>property-cycle</command> | |||
<property>/autopilot/autobrake/setting</property> | |||
<value type="string">ARM</value> | |||
<value type="string">DISARM</value> | |||
<value type="string">OFF</value> | |||
</binding> | </binding> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 88: | Line 85: | ||
<syntaxhighlight lang="xml"> | <syntaxhighlight lang="xml"> | ||
<binding> | <binding> | ||
<command>property-interpolate</command> | |||
<property>/controls/flight/aileron-trim</property> | |||
<value type="double">0</value> | |||
<rate>0.5</rate><!-- 2 seconds to 0 from 1 or -1 --> | |||
</binding> | </binding> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 98: | Line 95: | ||
<syntaxhighlight lang="xml"> | <syntaxhighlight lang="xml"> | ||
<binding> | <binding> | ||
<command>property-interpolate</command> | |||
<property>/controls/flight/aileron-trim</property> | |||
<value type="double">0</value> | |||
<time>2</time><!-- 2 seconds to 0 from 1, 0.5, -1 etc. --> | |||
</binding> | </binding> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 108: | Line 105: | ||
<syntaxhighlight lang="xml"> | <syntaxhighlight lang="xml"> | ||
<binding> | <binding> | ||
<command>property-interpolate</command> | |||
<property>/controls/flight/aileron-trim</property> | |||
<property>/controls/flight/default-aileron-trim</property><!-- the value to interpolate to, is 0 --> | |||
<rate>0.5</rate><!-- 2 seconds to 0 from 1 or -1 --> | |||
</binding> | </binding> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 119: | Line 116: | ||
<syntaxhighlight> | <syntaxhighlight> | ||
<binding> | <binding> | ||
<command>property-multiply</command> | |||
<property>/controls/flight/aileron</property> | |||
<factor>0.5</factor> | |||
<min>-1</min> | |||
<max>1</max> | |||
<mask>all</mask> | |||
<wrap>true</wrap> | |||
</binding> | </binding> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 139: | Line 136: | ||
=== property-randomize === | === property-randomize === | ||
Assigns a random value (between min and max) to a property. | Assigns a random value (between min and max) to a property. | ||
<syntaxhighlight> | <syntaxhighlight lang="xml"> | ||
<binding> | <binding> | ||
<command>property-randomize</command> | |||
<property>/orientation/pitch-deg</property> | |||
<min>0</min> | |||
<max>360</max> | |||
</binding> | </binding> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 150: | Line 147: | ||
=== property-scale === | === property-scale === | ||
Set the value of a property based on an axis, often used in [[joystick]] configuration files. | Set the value of a property based on an axis, often used in [[joystick]] configuration files. | ||
<syntaxhighlight> | <syntaxhighlight lang="xml"> | ||
<binding> | <binding> | ||
<command>property-scale</command> | |||
<property>/controls/flight/aileron</property> | |||
<offset>0.001</offset> | |||
<factor>-1</factor> | |||
<power>3</power> | |||
</binding> | </binding> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 169: | Line 166: | ||
=== property-swap === | === property-swap === | ||
Swaps the values of two properties, useful for radio panels. | Swaps the values of two properties, useful for radio panels. | ||
<syntaxhighlight> | <syntaxhighlight lang="xml"> | ||
<binding> | <binding> | ||
<command>property-swap</command> | |||
<property>/instrumentation/comm/frequencies/selected-mhz</property> | |||
<property>/instrumentation/comm/frequencies/standby-mhz</property> | |||
</binding> | </binding> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 179: | Line 176: | ||
=== property-toggle === | === property-toggle === | ||
Toggles the value of a property on each click, between true (1) and false (0). | Toggles the value of a property on each click, between true (1) and false (0). | ||
<syntaxhighlight> | <syntaxhighlight lang="xml"> | ||
<binding> | <binding> | ||
<command>property-toggle</command> | |||
<property>/controls/gear/gear-down</property> | |||
</binding> | </binding> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Or - if defined - it toggles between two custom values. | Or - if defined - it toggles between two custom values. | ||
<syntaxhighlight> | <syntaxhighlight lang="xml"> | ||
<binding> | <binding> | ||
<command>property-toggle</command> | |||
<property>/controls/gear/gear-down</property> | |||
<value>2</value> | |||
<value>3</value> | |||
</binding> | </binding> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 198: | Line 195: | ||
{{cquote| | {{cquote| | ||
<syntaxhighlight lang="nasal"> | <syntaxhighlight lang="nasal"> | ||
fgcommand("request-metar", | fgcommand("request-metar", props.Node.new({"path": "/foo/mymetar", "station": "LOWI"})); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 208: | Line 205: | ||
== Related content == | == Related content == | ||
* | * {{readme file|commands}} | ||
* [[Howto:Make a clickable panel]] | * [[Howto:Make a clickable panel]] | ||
* [[Howto:Reassign keyboard bindings]] | * [[Howto:Reassign keyboard bindings]] |