Conditions: Difference between revisions

Jump to navigation Jump to search
Added static values to supported elements
(Added static values to supported elements)
Line 1: Line 1:
{{Stub}}
{{Stub}}
'''Conditions''' (or '''SGConditions''') in the SimGear library are a property-based representation of custom conditions based on comparing property values. They can be evaluated from both C++ and Nasal (see simgear/props/condition.hxx and [[$FG_ROOT]]/Nasal/props.nas). Comparison of string-typed properties involves lexicographic ordering, as specified by the C++ operators <tt>&lt;</tt> and <tt>&gt;</tt>.
'''Conditions''' (or '''<code>SGCondition</code>s''') in the SimGear library are a property-based representation of custom conditions based on comparing property values. They can be evaluated from both C++ and Nasal (see <code>$SGSOURCE/simgear/props/condition.hxx</code> and <code>[[$FG_ROOT]]/Nasal/props.nas</code>). Comparison of string-typed properties involves lexicographic ordering, as specified by the C++ operators <tt>&lt;</tt> and <tt>&gt;</tt>.


== Usage ==
== Usage ==
Line 7: Line 7:
* State machines
* State machines
* Various parts of [[HUD]]s, 2D panels, [[PUI]]/XML dialogs
* Various parts of [[HUD]]s, 2D panels, [[PUI]]/XML dialogs
And several other places.
* Autopilot / PropertyRule systems
… and several other places.


== Sample Expressions ==
== Sample conditions ==
This is a sample expression for checking if the throttle on the first engine is above half:
This is a sample expression for checking if the throttle on the first engine is above half:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
Line 21: Line 22:


== Supported elements ==
== Supported elements ==
Each comparison (like less-than or greater-than-equals) requires either two <tt>&lt;property&gt;</tt> elements (the first with index=0 and the second with index=1) or a <tt>&lt;property&gt;</tt> (considered first) and <tt>&lt;value&gt;</tt> (considered second); booleans compare each of their child conditions. A <tt>&lt;condition&gt;</tt> element itself functions as an <tt>&lt;and&gt;</tt> element; that is, it can have several children, all of which must be true to make the whole condition true.
Each comparison (like <code>less-than</code> or <code>greater-than-equals</code>) requires either two <code>&lt;property&gt;</code> elements (the first with index=0 and the second with index=1) or a <code>&lt;property&gt;</code> (considered first) and <code>&lt;value&gt;</code> (considered second); booleans compare each of their child conditions. A <code>&lt;condition&gt;</code> element itself functions as an &lt;and<tt>&gt;</tt> element; that is, it can have several children, all of which must be true to make the whole condition true.
<syntaxhighlight lang="xml" enclose="div">
<syntaxhighlight lang="xml" enclose="div">
<and>
<and>
Line 33: Line 34:
<greater-than-equals>
<greater-than-equals>
<property> <!-- evaluates boolean value of specified property -->
<property> <!-- evaluates boolean value of specified property -->
<false/> <!-- static false value (<value> does NOT work in conditions !)-->
<true/><!-- static true value -->
</syntaxhighlight>
</syntaxhighlight>


97

edits

Navigation menu