Difference between revisions of "Bootstrap Element (Data)"
(→The "assignval" Element)
|Line 94:||Line 94:|
<autotag group="TheGroup" tag="TheTag"/>
<autotag group="TheGroup" tag="TheTag"/>
Revision as of 17:58, 19 February 2009
The "bootstrap" Element
In a variety of situations, you will be able to specify individual things that should be automatically added to a container as picks. This process is called bootstrapping and has a diverse set of special rules that must be observed. Each bootstrapped thing is specified through the use of a "bootstrap" element. The complete list of attributes for this element is below.
thing Id – Specifies the unique id of the thing that is to be automatically added to the container. index (Optional) Integer – Specifies a unique index value for this bootstrap entry. Only global bootstraps that add things to all actors require this attribute and it can be omitted in all other situations. Default: "0".
WARNING! The index is used to uniquely identify this specific bootstrap within saved portfolios. Consequently, it must never be changed or re-used within different versions of the data files. If you eliminate a bootstrap entry, simply leave that index value unused, replacing the old "bootstrap" element with a comment explaining why the hole in numbering is left.
The "bootstrap" element also possesses child elements that pertain to the automatically added things. The list of these child elements is below and must appear in the order shown. Click on the link to access the details for each element.
match An optional "match" element may appear as defined by the given link. This element defines the Match Tag Expression. If omitted, all things are assumed to match and the bootstrap is assigned to all.
IMPORTANT! This element is only applicable when the bootstrap is defined directly within a component. In all other cases, this element may not be specified.
containerreq An optional "containerreq" element may appear as defined by the given link. This element defines the conditional requirements that determine whether the bootstrap is made available within the container. The tag expression is applied against the container of the prospective bootstrapped pick. If the container does not satisfy the tag expression, the bootstrapped pick is treated as non-live.
IMPORTANT! This element is not applicable when the bootstrap is defined within an entity.
autotag Zero or more "autotag" elements may appear as defined by the given link. This element specifies tags that are automatically assigned to the added thing. assignval Zero or more "assignval" elements may appear as defined by the given link. This element specifies modified field values that are automatically assigned to the added thing.
The "match" Element
The "match" element defines the Match tag expression that determines whether a particular thing receives the specified bootstrap. The tag expression is applied against each thing derived from the component, and the bootstrap is only assigned to things that satisfy the tag expression. The complete list of attributes for this element is below.
PCDATA TagExpr – Specifies the code comprising the Match tag expression.
The "assignval" Element
All of the initial field values for a pick are dictated by the thing. However, there are situation where you'll want to dictate custom field values when bootstrapping a thing. For example, if you have a "Fly" ability, there may be different flying speeds. The "Fly" ability will have its initial speed, but each situation where you bootstrap the ability may call for a different speed.
To handle this situation, the "assignval" element allows you to designate the initial value to be used for a field within a bootstrapped pick. The complete list of attributes for this element is below.
field Id – Specifies the unique id of the field for which the value is being assigned. value Text – Specifies the new starting value to be assigned to the field. If the field is text-based, the value is simply assigned, although it may be truncated if it exceeds the defined maximum length for the field. If the field is value-based, the text is converted to a floating point value and assigned. behavior (Optional) Set – Designates the assignment behavior to be used if the thing is unique and has already been added to the container. An ability like "Fly" is likely to be unique, so it's possible that the ability is bootstrapped by multiple sources or even user-selected. When this occurs, you can stipulate the rules for how the new value is assigned to the field. Must be one of these values:
- assign – The new value overrides any existing value.
- minimum – Use the lowest of the new value and any existing value.
- maximum – Use the highest of the new value and any existing value.
- Default: "assign".
NOTE! There are a variety of important limitations that apply to the assignment of field values via bootstraps. These include the following:
- Non-persistent, derived fields may have their values specified freely.
- All other derived fields and all non-user fields may not be assigned via bootstraps.
- No array-based or matrix-based fields may be assigned via bootstraps.
- User fields may be assigned, but there are additional restrictions (see below).
- Value assignment only occurs for bootstraps that satisfy all their condition tests (e.g. ContainerReq tests).
- If multiple bootstraps attempt to assign the same field value to a unique pick, the values are assigned in the order they are processed by the engine, which is dictated by evaluation timing.
- If two or more value assignments are applied at the exact same timing, then there is *no* guarantee which will take precedence over the other.
- If a bootstrap has condition tests (e.g. ContainerReq tests), the value assignment is applied when the final condition test is resolved for the pick.
Fields of type "user" may be assigned via bootstraps. However, user field incur a number of additional restrictions, as outlined below:
- Cannot be used with conditional bootstraps (only derived fields may)
- Cannot be used with unique things, since the assigned value could overwrite an existing user-modified value
- Specified value is initialized as the default user value when the pick is first added and is thereafter allowed to be modified by the user
- The "maximum" and "minimum" behaviors are pointless with user values, since the value will always be the initial value assigned
The following example demonstrates what a "bootstrap" element might look like. All default values are assumed for optional attributes.
<bootstrap thing="AttrIncr"> <containerreq phase="Setup" priority="500"> val:Level.? >= 4 </container> <autotag group="TheGroup" tag="TheTag"/> <assignval field="MyField" value="42"/> </bootstrap>