Difference between revisions of "Oblivion XML Reference/Operators"
Jump to navigation
Jump to search
selectors
imported>DavidJCobb (→Other operators: listed) |
imported>DavidJCobb (selectors) |
||
Line 28: | Line 28: | ||
:The value that has been computed right up to an operator being processed. | :The value that has been computed right up to an operator being processed. | ||
;to select | ;to select | ||
:To pull a value from somewhere else, using the ''src'' and ''trait'' attributes. | :To pull a value from somewhere else, using the ''src'' and ''trait'' attributes. The ''src'' attribute can be the name of any tile in the menu, or a special code called a "[[#Selectors|selector]]." | ||
;to return | ;to return | ||
:The act of providing a result. As an example, the ''mult'' operator multiplies the argument by the current working value, and "returns" the result. The returned value then becomes the next operator's current working value. | :The act of providing a result. As an example, the ''mult'' operator multiplies the argument by the current working value, and "returns" the result. The returned value then becomes the next operator's current working value. | ||
Line 34: | Line 34: | ||
In the above code sample, the ''add'' operator has a current working value of 1, and an argument of 2. | In the above code sample, the ''add'' operator has a current working value of 1, and an argument of 2. | ||
== Copy operator == | == List of operators == | ||
=== Copy operator === | |||
The '''copy''' operator is used to overwrite the current working value: | The '''copy''' operator is used to overwrite the current working value: | ||
Line 80: | Line 81: | ||
* According to Bethesda’s code comments (in the stats menu), switch-cased strings only work on the first frame if the cases are defined before the ''copy'' operator is used. | * According to Bethesda’s code comments (in the stats menu), switch-cased strings only work on the first frame if the cases are defined before the ''copy'' operator is used. | ||
== Other operators == | === Other operators === | ||
;abs | ;abs | ||
:If the current working value is less than zero, then the operator’s argument is added to it, and the operator returns the absolute value of the result. Otherwise, the current working value is returned verbatim. | :If the current working value is less than zero, then the operator’s argument is added to it, and the operator returns the absolute value of the result. Otherwise, the current working value is returned verbatim. | ||
Line 134: | Line 135: | ||
;sub | ;sub | ||
:Subtracts the argument from the current working value, and returns the result. | :Subtracts the argument from the current working value, and returns the result. | ||
== Selectors == | |||
When specifying operators within a trait’s value, you can specify that the operator should pull its own value from a different trait defined on the same tile, or any trait defined on a different tile, by using the ''src'' attribute. The value of the ''src'' attribute can be the name of any tile in the same menu, or a special code called a '''selector'''. The selector searches for a tile according to some logic, and then "returns" that tile for use. | |||
Note that either way, ''src'' attribute values longer than 255 characters will be truncated. | |||
Selectors are special strings that can retrieve tiles based on their position relative to the current tile – that is, the tile specifying a trait that is using the selector. Every selector takes the format of the selector name, followed by a pair of parentheses; the parentheses may also contain an "argument," though not all selectors use these. The syntax looks like this: | |||
<copy src="selectorName(selectorArgument)" trait="desiredTrait" /> | |||
Internally, the selector returns (a pointer to) the tile, or it returns nothing (<code>nullptr</code>). If it returns a tile, the game will pull the specified trait from that tile; if the tile or the trait do not exist, the float 0.0 is used. | |||
;child | |||
:If an argument is specified, then this selector's searches the current tile’s child and descendant tiles for one with the same name as the passed-in argument, in backwards-sibling order; returns the found tile or nullptr. Otherwise, the selector returns the current tile’s last child or nullptr. | |||
:“Backwards-sibling order” is a clumsy improvised term to describe searching downward through the tile hierarchy, but iterating over child tiles in reverse order, such that a tile’s last child is checked before its first child. This reflects the order in which tiles are stored internally. | |||
;last | |||
:Code analysis indicates that this retrieves an unknown tile belonging to the current tile’s containing menu. It may return the last tile generated from a template. A specified argument will be ignored. | |||
;me | |||
:Retrieves the current tile. Use this to allow one trait on a tile to use the value of another trait on the same tile. A specified argument will be ignored. | |||
;parent | |||
:Returns the current tile’s parent tile. A specified argument will be ignored. | |||
;screen | |||
:A special-case tile maintained by the game engine; it exists outside of all menus. Its width, height, cropX, and cropY traits are set to the (normalized) screen dimensions and to the safe zone bounds. Internally, this tile serves as the “menu root” (and is identified as such by OBSE): it is the parent tile of all menus’ root tiles. | |||
;sibling | |||
:If an argument is specified, searches the current tile’s siblings for one with the same name as the passed-in argument; returns the found tile or nullptr. Otherwise, returns the current tile’s previous sibling or nullptr. | |||
;strings | |||
:A special-case tile maintained by the game engine; it exists outside of all menus. Its contents are defined by the strings.xml file; each string is an underscore-prefixed trait. Bethesda used this to make it easy to localize Oblivion for different languages. |