Difference between revisions of "Operator Element"

158 bytes added ,  08:37, 10 February 2012
m
imported>JRoush
imported>Kyoma
Line 2: Line 2:
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 evaluates in real time to get the property value.
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 evaluates in real time to get the property value.


There is pretty much an Operator Element for every basic mathematical operator - at least every operator that takes two operands. The first operand is always the current value of the property (i.e. the value after evaluation of the previous operator, or the value from the previous frame for the first operator).  If the operator contains a literal number or string, that is used as the second operand.  For example:
There is pretty much an Operator Element for every basic mathematical operator - at least every operator that takes two operands. The first operand is always the current value of the property (i.e. the value after evaluation of the previous operator, or the value from the previous update for the first operator).  If the operator contains a literal number or string, that is used as the second operand.  For example:
  <image>
  <image>
   <x>       
   <x>       
     <add> 1 </add>  &lt;!-- Add 1 to current x position --&gt;
    <copy> 1 </copy>  &lt;!-- Set the current x position to 1 --&gt;
     <add> 5 </add>  &lt;!-- Add 5 to current x position --&gt;
   </x>
   </x>
  </image>
  </image>
However, Operators can instead refer to ''properties'' for the value of their second operand, using the [[XML Attribute|src]] and [[XML Attribute|trait]] XML attributes.  This include properties of other object elements.  See the attributes page for details on this syntax.  An example:
However, Operators can instead refer to ''properties'' for the value of their second operand, using the [[XML Attribute|src]] and [[XML Attribute|trait]] XML attributes.  This include properties of other object elements.  See the attributes page for details on this syntax.  An example:
  <image name="example_image>
  <image name="example_image>
   <y> 5 </y>   
   <y> 5 </y>   
   <x>  &lt;!--Add the value of the y coordinate (5) to the current x position --&gt;
   <x>  &lt;!-- Set the current x position to the value of the y coordinate (5) --&gt;
     <add src="example_image" trait="y"/>  
     <copy src="example_image" trait="y"/>  
   </x>
   </x>
  </image>  
  </image>  
Line 19: Line 21:
  <image>
  <image>
   <x>
   <x>
     &lt;!-- New X = (X + 10) * 2 --&gt;
     &lt;!-- New X = (5 + 10) * 2 --&gt;
    <copy> 5 </copy>
     <add> 10 </add>
     <add> 10 </add>
     <mult> 2 </mult>  
     <mul> 2 </mul>  
   </x>
   </x>
  </image>
  </image>


Operator Elements may contain other operator elements as children to make more complicated formulas:
Operator Elements may contain other operator elements as children to make more complicated formulas or for when operator precedence is needed:
  <image>
  <image>
   <x>
   <x>
     &lt;!-- New X = X + (10 / 3) --&gt;
     &lt;!-- New X = 5 + (10 / 3) --&gt;
    <copy> 5 </copy>
     <add>  
     <add>  
       <copy> 10 </copy>
       <copy> 10 </copy>
Anonymous user