Difference between revisions of "Operator Element"
imported>JRoush m (→Copy Operator) |
imported>JRoush m (→Overview) |
||
Line 1: | Line 1: | ||
{{unfinished}} | {{unfinished}} | ||
== Overview == | == Overview == | ||
Operator Elements are a subgroup of the elements in the [[:Category: Oblivion XML|Oblivion XML]] schema, always found as children of [[Property Element]]s. They are used to create mathematical formulas, which the game engine can evaluate to obtain a value for the parent property. | |||
There is, generally speaking, an Operator Element for every basic ''binary'' mathematical operator - every operator that takes exactly two operands. The first operand is always the current value of the property, and the second is the contents of the operator. For example: | There is, generally speaking, an Operator Element for every basic ''binary'' mathematical operator - every operator that takes exactly two operands. The first operand is always the current value of the property, and the second is the contents of the operator. For example: |
Revision as of 10:35, 19 December 2009
This article has been marked by editors or authors as incomplete. Please see the Talk page for details. Discussion and collaboration can improve an article and lead to a better Wiki.
Overview
Operator Elements are a subgroup of the elements in the Oblivion XML schema, always found as children of Property Elements. They are used to create mathematical formulas, which the game engine can evaluate to obtain a value for the parent property.
There is, generally speaking, an Operator Element for every basic binary mathematical operator - every operator that takes exactly two operands. The first operand is always the current value of the property, and the second is the contents of the operator. For example:
<image> <x> <add> 1 </add> <!-- Add one to current x position --> </x> </image>
A property element may contain a series of Operators, which are evaluated in order:
<image> <x> <!-- New X = (X + 10) * 2 --> <add> 10 </add> <mult> 2 </mult> </x> </image>
Operator Elements may contain other operator elements as children:
<image> <x> <!-- New X = X + (10 / 3) --> <add> <copy> 10 </copy> <div> 3 </div> </add> </x> </image>
Operator Elements may contain the value of a property for some other element somewhere in the menu:
<image> <x> <!-- Place this image 10 pixels to the right of the "ExitButton" element --> <copy src="ExitButton" trait="x"/> <add src="ExitButton" trait="width"/> <add> 10 </add> </x> </image>
Here src and trait are XML traits indicating the source element and property, respectively. Don't be confused by the use of the word 'trait' in the latter case - it's actually referring to a element (specifically a 'property' element).
Copy Operator
The only unary (single-operand) operator. The <copy> operator replaces the current property value with its contents:
<image> <x> <!-- Set the new x position to be 50 pixels --> <Copy> 50 </Copy> </x> </image>
Algebraic Operators
These should be self-explanatory.
- Add
- Sub
- Mult/Mul - different elements, but both perform exactly the same function.
- Div - floating point, rather than integer, division
Boolean Operators
With these operators the numerical value of 'true' is encoded as the XML entity "&true;", or the literal number 2. The standard numerical value of 'false' is "&false;", or 1, but any number other than 2 will be considered false.
- Onlyif - The new property value is the current property value if the contents of <onlyif> evaluate to &true;, and zero if the contents evaluate to &false;.
- Onlyifnot - Similar to <onlyif>, but with the opposite pairing.
- Lt - The new property value is &true; if the current value is less than the contents of <lt>, and &false; otherwise.
- Gt - Similar to <lt>, but the current value must be greater than the contents of <gt>.
- Eq - The new property value is &true; if the current value is equal to the contents of <eq>, and &false; otherwise.
- Neq - Similar to <eq>, but the current value must be unequal to the contents of <neq>.
Comparative Operators
- Min - The new value is current value or the contents of <min>, whichever is greater.
- Max - The new value is the current value or the contents of <max>, whichever is less.