97
edits
(→Usage) |
(Added static values to supported elements) |
||
Line 1: | Line 1: | ||
{{Stub}} | {{Stub}} | ||
'''Conditions''' (or ''' | '''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><</tt> and <tt>></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 | ||
* Autopilot / PropertyRule systems | |||
… and several other places. | |||
== Sample | == 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 < | Each comparison (like <code>less-than</code> or <code>greater-than-equals</code>) requires either two <code><property></code> elements (the first with index=0 and the second with index=1) or a <code><property></code> (considered first) and <code><value></code> (considered second); booleans compare each of their child conditions. A <code><condition></code> element itself functions as an <and<tt>></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> | ||
edits