Deletion Script: Difference between revisions

From HLKitWiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 12: Line 12:
|Fields Finalized?
|Fields Finalized?
|No
|No
|-
|Where Used:
|[[Component Element (Data)|Components]]
|-
|-
|}
|}

Revision as of 00:10, 16 December 2008

Context: HL Kit … Kit Reference … Script Types 

Technical Details

Initial Context: Pick
Alternate Context: None
Fields Finalized? No
Where Used: Components

The Integrity script utilizes the following special symbols:

-None- There are no special symbols for a Deletion script.

Description

The Deletion script is the analog of the Creation script. The script pertains to all picks that are derived from a given component, and it is invoked a single time just before a pick is finally destroyed. As such, its primary use is for performing special wrapup handling of picks.

This script is rarely used, but it is quite necessary in those places. The easiest example is with usage pools, such as those used by the journal mechanism. Each journal pick adds its awards (e.g. XP, cash) to the overall usage pools maintained for the actor. But if the user deletes a journal pick, it's critical that the awards conferred by the pick be subtracted back out. Enter the Deletion script, which serves perfectly for this purpose.

When invoked, a Deletion script starts with the pick as its initial context. There is generally no reason to navigate outside the context of the pick, but it is technically allowed. The primary focus will be on the pick and its fields.

Example

Using the example cited above, the Deletion script below will properly subtract out the adjustments from a journal pick before it is destroyed.

perform hero.usagepool[TotalXP].adjust[-usagepool[JrnlXP].value]
perform hero.usagepool[TotalCash].adjust[-usagepool[JrnlCash].value]