Bindings: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
(→‎property-adjust: replaced incorrect "factor" with "step", added comments)
(24 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Incomplete}}
'''Bindings''' define what happens when a user:
* [[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 (clicking a button, selecting list entries etc)
 
In other words, '''bindings''' are simply the term for '''actions''' that are associated with certain '''events''' in FlightGear.
 
There are different types of events supported by various subsystems, but the resulting action that can be triggered will typically involve either a hard-coded command (a so called fgcommand), or a block of scripted code (using [[Nasal]]). Bindings can be parameterized/customized using properties as arguments that are passed to each binding as a props.Node object.
And Nasal code can also be registered to become available as a dedicated fgcommand.
 
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.


'''Bindings''' define what happens when a user:
* [[Howto: Make a clickable panel#Pick|clicks an object]] in the [[scenery]] or an [[aircraft]]
* press a key on the keyboard or [[joystick]]
* clicks a [[menu]] item
* click a buttons or fields in a dialog
You can assign multiple bindings to one object/button/key. Each binding may contain one [[conditions|condition]] element to make it 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 <tt>[[$FG_ROOT]]/Docs/README.commands</tt> for additional information and a complete list of available bindings.
{{Note|Planes are free to override key bindings to fullfill their needs. The Space Shuttle for instance has no mixture control, so the m-key switches from translational to rotational hand controller.
The key only performs as mixture control if the plane has mixture settings and if the plane didn't re-assign the key - so dependent on what plane you try, it may or may not. Usually the aircraft-specific help spells it out.<ref>{{cite web
  |url    =  https://forum.flightgear.org/viewtopic.php?p=298436#p298436
  |title  =  <nowiki> Re: trouble with m-key </nowiki>
  |author =  <nowiki> Thorsten </nowiki>
  |date  =  Nov 9th, 2016
  |added  =  Nov 9th, 2016
  |script_version = 0.40
  }}</ref>
}}
 
This article gives a small overview of frequently used bindings. Please refer to {{readme file|commands}} for additional information and refer to $FG_SRC/Main/commands.cxx for 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 some useful commands, some also with their equivalent Nasal call.  A more complete listing can be found in the readme file, {{readme file|commands}}.


Below are a number of useful commands. See further [http://mapserver.flightgear.org/git/?p=flightgear;a=blob;f=src/Main/fg_commands.cxx;h=4c3272916f56a3180e29b9d8457e697bb71cfecb;hb=HEAD#l1555 fg_commands.cxx].  
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]]
=== replay ===
Toggles replay.
<syntaxhighlight lang="xml">
<binding>
  <command>replay</command>
</binding>
</syntaxhighlight>
<syntaxhighlight lang="nasal">
fgcommand("replay");
</syntaxhighlight>


=== dialog-close ===
=== dialog-close ===
Closes the active dialog.
Closes the active dialog.
<syntaxhighlight>
<syntaxhighlight lang="xml">
<binding>
<binding>
<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><Current 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>
<syntaxhighlight lang="xml">
<binding>
<binding>
<command>dialog-show</command>
  <command>dialog-show</command>
<dialog-name>location-in-air</dialog-name>
  <dialog-name>location-in-air</dialog-name>
</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 ===
[[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>
  <command>nasal</command>
<script>b777.afds.input(0,1);</script>
  <script>b777.afds.input(0,1);</script>
</binding>
</binding>
</syntaxhighlight>
</syntaxhighlight>
The [[List of Nasal extension functions#cmdarg.28.29|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.
; 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.
 
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 ===
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>
  <command>property-adjust</command>
<property>/autopilot/settings/heading-bug-deg</property>
  <property>/autopilot/settings/heading-bug-deg</property>
<step>1</step>    <!-- will add 1 to /autopilot/settings/heading-bug-deg whenever this binding is called -->
  <step>1</step>
<min>000</min>    <!-- the property will never be allowed to go below 0 -->
  <min>0</min>
<max>360</max>    <!-- ...or above 360 -->
  <max>360</max>
<wrap>true</wrap> <!-- when we hit 361, wrap back to 0 and vice-versa -->
  <wrap>true</wrap>
</binding>
</binding>
</syntaxhighlight>
</syntaxhighlight>
; property : Property that will be changed.
; step    : Amount to increase or decrease the property's value. Defaults to 0.
; offset  : Offset from the property's current value. If '''step''' is not given, this is multiplied by '''factor'''.
; factor  : When '''step''' is not given, '''offset''' is multiplied by this. Defaults to 1.
; min      : The minimum allowed value. Defaults to "no minimum."
; max      : The maximum allowed value. Defaults to "no maximum."
; wrap    : If true, the value will be wrapped when it passes min or max; both min and max must be present for this to work. Defaults to false.
; mask    : This argument accepts three value: "integer," "decimal" and "all" (default). "integer" means that '''step''' or '''offset * factor''' is applied to the part of the property's current value left of the decimal point first. "decimal" does the same, but applies it to the prt to the right of the decimal point. "all" simply applies it to the whole number. This parameter does not seem to affect the resulting new value of the property, and so is not needed.


=== 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>
  <command>property-assign</command>
<property>/autopilot/settings/target-speed-kt</property>
  <property>/autopilot/settings/target-speed-kt</property>
<value>0</value>
  <value>0</value>
</binding>
</binding>
</syntaxhighlight>
</syntaxhighlight>
Line 73: Line 119:
=== 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>
  <command>property-cycle</command>
<property>/autopilot/autobrake/setting</property>
  <property>/autopilot/autobrake/setting</property>
<value type="string">ARM</value>
  <value type="string">ARM</value>
<value type="string">DISARM</value>
  <value type="string">DISARM</value>
<value type="string">OFF</value>
  <value type="string">OFF</value>
</binding>
</binding>
</syntaxhighlight>
</syntaxhighlight>
Line 88: Line 134:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<binding>
<binding>
<command>property-interpolate</command>
  <command>property-interpolate</command>
<property>/controls/flight/aileron-trim</property>
  <property>/controls/flight/aileron-trim</property>
<value type="double">0</value>
  <value type="double">0</value>
<rate>0.5</rate><!-- 2 seconds to 0 from 1 or -1 -->
  <rate>0.5</rate><!-- 2 seconds to 0 from 1 or -1 -->
</binding>
</binding>
</syntaxhighlight>
</syntaxhighlight>
Line 98: Line 144:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<binding>
<binding>
<command>property-interpolate</command>
  <command>property-interpolate</command>
<property>/controls/flight/aileron-trim</property>
  <property>/controls/flight/aileron-trim</property>
<value type="double">0</value>
  <value type="double">0</value>
<time>2</time><!-- 2 seconds to 0 from 1, 0.5, -1 etc. -->
  <time>2</time><!-- 2 seconds to 0 from 1, 0.5, -1 etc. -->
</binding>
</binding>
</syntaxhighlight>
</syntaxhighlight>
Line 108: Line 154:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<binding>
<binding>
<command>property-interpolate</command>
  <command>property-interpolate</command>
<property>/controls/flight/aileron-trim</property>
  <property>/controls/flight/aileron-trim</property>
<property>/controls/flight/default-aileron-trim</property><!-- the value to interpolate to, is 0 -->
  <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 -->
  <rate>0.5</rate><!-- 2 seconds to 0 from 1 or -1 -->
</binding>
</binding>
</syntaxhighlight>
</syntaxhighlight>
Line 119: Line 165:
<syntaxhighlight>
<syntaxhighlight>
<binding>
<binding>
<command>property-multiply</command>
  <command>property-multiply</command>
<property>/controls/flight/aileron</property>
  <property>/controls/flight/aileron</property>
<factor>0.5</factor>
  <factor>0.5</factor>
<min>-1</min>
  <min>-1</min>
<max>1</max>
  <max>1</max>
<mask>all</mask>
  <mask>all</mask>
<wrap>true</wrap>
  <wrap>true</wrap>
</binding>
</binding>
</syntaxhighlight>
</syntaxhighlight>
Line 139: Line 185:
=== 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>
  <command>property-randomize</command>
<property>/orientation/pitch-deg</property>
  <property>/orientation/pitch-deg</property>
<min>0</min>
  <min>0</min>
<max>360</max>
  <max>360</max>
</binding>
</binding>
</syntaxhighlight>
</syntaxhighlight>
Line 150: Line 196:
=== 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>
  <command>property-scale</command>
<property>/controls/flight/aileron</property>
  <property>/controls/flight/aileron</property>
<offset>0.001</offset>
  <offset>0.001</offset>
<factor>-1</factor>
  <factor>-1</factor>
<power>3</power>
  <power>3</power>
</binding>
</binding>
</syntaxhighlight>
</syntaxhighlight>
Line 165: Line 211:
* '''power:''' the resulting value will be taken to the power of this integer value (overrides squared).
* '''power:''' the resulting value will be taken to the power of this integer value (overrides squared).


Remember: <tt>((property+offset)*factor)^power=result</tt>
Remember: <tt>(property^power + offset) * factor = result</tt>


=== 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>
  <command>property-swap</command>
<property>/instrumentation/comm/frequencies/selected-mhz</property>
  <property>/instrumentation/comm/frequencies/selected-mhz</property>
<property>/instrumentation/comm/frequencies/standby-mhz</property>
  <property>/instrumentation/comm/frequencies/standby-mhz</property>
</binding>
</binding>
</syntaxhighlight>
</syntaxhighlight>
Line 179: Line 225:
=== 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>
  <command>property-toggle</command>
<property>/controls/gear/gear-down</property>
  <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>
  <command>property-toggle</command>
<property>/controls/gear/gear-down</property>
  <property>/controls/gear/gear-down</property>
<value>2</value>
  <value>2</value>
<value>3</value>
  <value>3</value>
</binding>
</binding>
</syntaxhighlight>
</syntaxhighlight>
Line 198: Line 244:
{{cquote|
{{cquote|
<syntaxhighlight lang="nasal">
<syntaxhighlight lang="nasal">
fgcommand("request-metar", var n = props.Node.new({ "path": "/foo/mymetar", "station":"LOWI"}));
fgcommand("request-metar", props.Node.new({"path": "/foo/mymetar", "station": "LOWI"}));
</syntaxhighlight>
</syntaxhighlight>


Line 206: Line 252:
<references/>
<references/>


== Related content ==
=== Wiki ===
* [[Howto:Make a clickable panel]]
* [[Howto:Reassign keyboard bindings]]


== Related content ==
=== Forum topics ===
* <tt>[[$FG_ROOT]]/Docs/README.commands</tt> [https://gitorious.org/fg/fgdata/blobs/master/Docs/README.commands view online]
* {{forum link|t=37443|title=Order of multiple bindings}}
* [[Howto: Make a clickable panel]]
* {{forum link|t=37447|title=Amending to key bindings}} - Partially about indices (<code><nowiki><binding n="<index>"></nowiki></code>) for bindings.
 
=== Readme file ===
* {{readme file|commands}}
 
=== Source ===
Note that many commands are defined elsewhere. The readme file has a more complete listing.
 
* {{flightgear source|path=src/Main/fg_commands.hxx}}
* {{flightgear source|path=src/Main/fg_commands.cxx}}


[[Category:Development]]
[[Category:Development]]
[[Category:XML]]
[[Category:XML]]
[[Category:FlightGear keyboard]]
[[Category:Joysticks and Yokes]]

Revision as of 12:14, 30 June 2020

Bindings define what happens when a user:

In other words, bindings are simply the term for actions that are associated with certain events in FlightGear.

There are different types of events supported by various subsystems, but the resulting action that can be triggered will typically involve either a hard-coded command (a so called fgcommand), or a block of scripted code (using Nasal). Bindings can be parameterized/customized using properties as arguments that are passed to each binding as a props.Node object. And Nasal code can also be registered to become available as a dedicated fgcommand.

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.


Note  Planes are free to override key bindings to fullfill their needs. The Space Shuttle for instance has no mixture control, so the m-key switches from translational to rotational hand controller.

The key only performs as mixture control if the plane has mixture settings and if the plane didn't re-assign the key - so dependent on what plane you try, it may or may not. Usually the aircraft-specific help spells it out.[1]

This article gives a small overview of frequently used bindings. Please refer to $FG_ROOT/Docs/README.commands for additional information and refer to $FG_SRC/Main/commands.cxx for a complete list of available bindings.

All given codes are examples, found on various places in the FlightGear package.

Commands

Below are some useful commands, some also with their equivalent Nasal call. A more complete listing can be found in the readme file, $FG_ROOT/Docs/README.commands.

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

replay

Toggles replay.

<binding>
  <command>replay</command>
</binding>
fgcommand("replay");

dialog-close

Closes the active dialog.

<binding>
  <command>dialog-close</command>
</binding>
fgcommand("dialog-close");

dialog-show

Shows a dialog, which should be present in $FG_ROOT/gui/dialogs. In addition, from FlightGear 2.8, dialog files located in <aircraft directory>/gui/dialogs are also loaded. This should be used for dialogs specific to a certain aircraft.

<binding>
  <command>dialog-show</command>
  <dialog-name>location-in-air</dialog-name>
</binding>
fgcommand("dialog-show", props.Node.new({"dialog-name": "location-in-air"}));
dialog-name
The name of the dialog, as designated in its XML file.

nasal

Nasal is frequently used for complicated systems, because it can execute virtually any function and allows running previously-defined Nasal functions.

<binding>
  <command>nasal</command>
  <script>b777.afds.input(0,1);</script>
</binding>
script
The Nasal script to execute.
Note Make sure that the script does not conflict with the predefined XML entities This is a link to a Wikipedia article. If it does, you can either put it in a CDATA section This is a link to a Wikipedia article or use a non-interpreted version (e.g., &gt; in place of >).

The cmdarg() function is often useful in these situations to extract offset values passed to the binding. It returns the specific <binding> node, which contains a <setting> 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 see Howto:Understand Namespaces and Methods for more information on namespaces.

property-adjust

Increases or decreases a property's value with a given step. Maximum and minimum values are optional.

<binding>
  <command>property-adjust</command>
  <property>/autopilot/settings/heading-bug-deg</property>
  <step>1</step>
  <min>0</min>
  <max>360</max>
  <wrap>true</wrap>
</binding>
property
Property that will be changed.
step
Amount to increase or decrease the property's value. Defaults to 0.
offset
Offset from the property's current value. If step is not given, this is multiplied by factor.
factor
When step is not given, offset is multiplied by this. Defaults to 1.
min
The minimum allowed value. Defaults to "no minimum."
max
The maximum allowed value. Defaults to "no maximum."
wrap
If true, the value will be wrapped when it passes min or max; both min and max must be present for this to work. Defaults to false.
mask
This argument accepts three value: "integer," "decimal" and "all" (default). "integer" means that step or offset * factor is applied to the part of the property's current value left of the decimal point first. "decimal" does the same, but applies it to the prt to the right of the decimal point. "all" simply applies it to the whole number. This parameter does not seem to affect the resulting new value of the property, and so is not needed.

property-assign

One of the most important commands. It sets a property to a predefined value.

<binding>
  <command>property-assign</command>
  <property>/autopilot/settings/target-speed-kt</property>
  <value>0</value>
</binding>

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.

<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>

As of May 2013, the command supports additional behaviours to simplify use with the new knob and slider animations. The wrapping behaviour can be disabled by setting <wrap>0</wrap>, and the command uses the 'offset' argument to select a direction of movement. This means a property-cycle bound to a multi-position knob will function as expected for movement in both directions.

property-interpolate

Interpolates to a value with a given rate of change (per second).

<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>

Instead of using <rate>, one could use

<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>

You can also interpolate to a value given by a property.

<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>

property-multiply

Multiply the value of a property by a given factor.

<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>
  • factor: the amount to multiply by.
  • min: minimum value.
  • max: maximum value.
  • mask:
    • integer: mutiply only left of the decimal point.
    • decimal: multiply only the right of the decimal point.
    • all: multiply the entire value.
  • wrap: true if the value should be wrapped if it passes min/max. It is required to set both min and max in that case.

property-randomize

Assigns a random value (between min and max) to a property.

<binding>
  <command>property-randomize</command>
  <property>/orientation/pitch-deg</property>
  <min>0</min>
  <max>360</max>
</binding>

property-scale

Set the value of a property based on an axis, often used in joystick configuration files.

<binding>
  <command>property-scale</command>
  <property>/controls/flight/aileron</property>
  <offset>0.001</offset>
  <factor>-1</factor>
  <power>3</power>
</binding>
  • offset: the offset to shift by, before applying the factor.
  • factor: the factor to multiply by (use negative to reverse).
  • squared: if true will square the resulting value (same as power=2).
  • power: the resulting value will be taken to the power of this integer value (overrides squared).

Remember: (property^power + offset) * factor = result

property-swap

Swaps the values of two properties, useful for radio panels.

<binding>
  <command>property-swap</command>
  <property>/instrumentation/comm/frequencies/selected-mhz</property>
  <property>/instrumentation/comm/frequencies/standby-mhz</property>
</binding>

property-toggle

Toggles the value of a property on each click, between true (1) and false (0).

<binding>
  <command>property-toggle</command>
  <property>/controls/gear/gear-down</property>
</binding>

Or - if defined - it toggles between two custom values.

<binding>
  <command>property-toggle</command>
  <property>/controls/gear/gear-down</property>
  <value>2</value>
  <value>3</value>
</binding>

request-metar

Cquote1.png
fgcommand("request-metar", props.Node.new({"path": "/foo/mymetar", "station": "LOWI"}));

If you pass an existing path, the station ID will be updated, and if you pass the same station ID as before, no additional request is made. As usual for metar-properties, there's a time-to-live and valid flags you can check, and the metar refreshes automatically every 900 seconds. You can also write to the station ID directly to change station, update the time-to-live, and wait for the valid signal.

There's also an unregister command ('clear-metar') to cancel the binding into the property tree.[2]
— James Turner
Cquote2.png
  1. Thorsten  (Nov 9th, 2016).  Re: trouble with m-key .
  2. James Turner (Sun, 23 Sep 2012 08:56:48 -0700). [Flightgear-devel] Requesting arbitrary metar.

Related content

Wiki

Forum topics

Readme file

Source

Note that many commands are defined elsewhere. The readme file has a more complete listing.