Bound Script: Difference between revisions
New page: {{context|Kit Reference|Script Types}} ==Technical Details== :{| class="scripttable" |class="leftnormal"|Initial Context: |Pick |- |Alternate Context: |None |- |Fields F... |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 12: | Line 12: | ||
|Fields Finalized? | |Fields Finalized? | ||
|No | |No | ||
|- | |||
|Where Used: | |||
|[[Field Element (Data)|Field]] | |||
|- | |||
|Procedure Use: | |||
|"bounds" type, "pick" context | |||
|- | |- | ||
|} | |} | ||
Line 19: | Line 25: | ||
:{| class="infotable" | :{| class="infotable" | ||
|class="leftnormal"|minimum | |class="leftnormal"|minimum | ||
|Entry: The default minimum value to be used for bounding.<br> | |(Number) Entry: The default minimum value to be used for bounding.<br> | ||
Exit: The final minimum value to be used for bounding. | Exit: The final minimum value to be used for bounding. | ||
|- | |- | ||
|maximum | |maximum | ||
|Entry: The default maximum value to be used for bounding.<br> | |(Number) Entry: The default maximum value to be used for bounding.<br> | ||
Exit: The final maximum value to be used for bounding. | Exit: The final maximum value to be used for bounding. | ||
|- | |- |
Latest revision as of 08:42, 20 February 2009
Context: HL Kit … Kit Reference … Script Types
Technical Details
Initial Context: Pick Alternate Context: None Fields Finalized? No Where Used: Field Procedure Use: "bounds" type, "pick" context
The Bound script utilizes the following special symbols:
minimum (Number) Entry: The default minimum value to be used for bounding.
Exit: The final minimum value to be used for bounding.
maximum (Number) Entry: The default maximum value to be used for bounding.
Exit: The final maximum value to be used for bounding.
Description
The Bound script allows you to dynamically calculate the appropriate minimum and maximum values that a field can possess. This is invaluable when the minimums are dependent upon dynamically changing criteria. For example, consider the height and weight of a character. If the game system supports different races, then each race will have its own minimums and maximums for these characteristics. You need to be able to set the bounds based on the race that has been selected.
The Bound script begins with an initial context of the pick containing the field being bounded. This makes it possible to easily access other fields on the pick to base the bounding limits. The most common use of this script is for the containing pick to have separate fields that dictate the minimum and maximum values to be imposed. These fields are properly setup by Eval scripts and then the Bound script simply assigns those values as the limits.
When the Bound script is invoked, the minimum and maximum limits start out as the limits specified via the "minimum" and "maximum" attributes on the field definition. If no limits are defined via those attributes, then there is no limit on the field value. This makes it possible to have your Bound script use the defaults and only impose appropriate limits when necessary, leaving the limits unchanged otherwise.
Until a Bound script is invoked, the value of the field is bounded against the default limits specified by the field attributes. So any use of the field value within a script that occurs earlier than the Bound script will be restricted based on those limits. Once the Bound script is invoked, the current field value is immediately bounding to the new limits. Thereafter, any changes applied to the field value are automatically bounded to the new limits.
Example
The bounding of age, height, and weight uses the approach outlined above, where separate fields are used to dictate the appropriate bounding limits. As such, the Bound script for the character's age simply pulls its limits from the separate fields, as shown below.
@minimum = field[perAgeMin].value @maximum = field[perAgeMax].value