Procedure Element (Data): Difference between revisions
Line 42: | Line 42: | ||
integrate – Procedure may only be called from within an [[Integrate Script]].<br> | integrate – Procedure may only be called from within an [[Integrate Script]].<br> | ||
dossier – Procedure may only be called from within a [[Dossier Script]].<br> | dossier – Procedure may only be called from within a [[Dossier Script]].<br> | ||
none – Procedure may be called from '''any''' type of script. However, there is no initial context for identifiers, so no context transitions may be specified that don't explicitly designate a safe initial context (e.g. "hero."). This procedure type is useful when all inputs are passed via variables and all results returned via variables. Default: "unknown".<br> | none – Procedure may be called from '''any''' type of script. However, there is no initial context for identifiers, so no context transitions may be specified that don't explicitly designate a safe initial context (e.g. "hero."). This procedure type is useful when all inputs are passed via variables and all results returned via variables.<br> | ||
Default: "unknown".<br> | |||
{{note}}It is '''valid''' to setup a focus pick via "setfocus" within a calling script and then utilize the inherited focus pick within a procedure of type "none". | {{note}}It is '''valid''' to setup a focus pick via "setfocus" within a calling script and then utilize the inherited focus pick within a procedure of type "none". | ||
|- | |- |
Revision as of 03:33, 1 December 2008
Context: HL Kit … Kit Reference … Data File Reference
The "procedure" Element
If you need to invoke the same script code from multiple scripts, then you should consider writing a re-usable procedure that defines the code once and can be called from multiple scripts. Each procedure is defined through the use of a "procedure" element. The complete list of attributes for this element is below.
id Id – Specifies the unique id of the procedure. This id is used in all references to the procedure. context (Optional) Set – Designates a general script context from which this procedure is designed to be called. A script context spans multiple different script types that are related in nature and behavior. Must be one of these values:
unknown – Procedure may only be invoked from within a specific type of script, as dictated by the "scripttype" attribute (below).
pick – Procedure can be called from any script with a pick as its initial context.
container – Procedure can be called from any script with a container as its initial context.
entity – Procedure can be called from entity-related scripts, such as the Titlebar Script.
visual – Procedure can be called from any visual script, such as the Position Script.
info – Procedure can be called from any information synthesis script for a thing or pick, such as the MouseInfo Script.
transact – Procedure can be called from any transaction script, such as the TransactBuy Script.
combat – Procedure can be called from any combat-related script, such as the NewCombat Script.
Default: "unknown".scripttype (Optional) Set – Designates the specific script type from which this procedure may be called. The procedure may only be called from scripts of this type. Must be one of these values:
unknown – Procedure may be invoked from a general category of scripts, as dictated by the "context" attribute (above).
finalize – Procedure may only be called from within a Finalize Script.
calculate – Procedure may only be called from within a Calculate Script.
bounds – Procedure may only be called from within a Bound Script.
eval – Procedure may only be called from within an Eval Script.
evalrule – Procedure may only be called from within an EvalRule Script.
mouseinfo – Procedure may only be called from within a MouseInfo Script.
titlebar – Procedure may only be called from within a Titlebar Script.
description – Procedure may only be called from within a Description Script.
trigger – Procedure may only be called from within a Trigger Script.
label – Procedure may only be called from within a Label Script.
validate – Procedure may only be called from within a Validate Script.
xactsetup – Procedure may only be called from within a TransactSetup Script.
xactbuy – Procedure may only be called from within a TransactBuy Script.
xactsell – Procedure may only be called from within a TransactSell Script.
newcombat – Procedure may only be called from within a NewCombat Script.
newturn – Procedure may only be called from within a NewTurn Script.
integrate – Procedure may only be called from within an Integrate Script.
dossier – Procedure may only be called from within a Dossier Script.
none – Procedure may be called from any type of script. However, there is no initial context for identifiers, so no context transitions may be specified that don't explicitly designate a safe initial context (e.g. "hero."). This procedure type is useful when all inputs are passed via variables and all results returned via variables.
Default: "unknown".
NOTE! It is valid to setup a focus pick via "setfocus" within a calling script and then utilize the inherited focus pick within a procedure of type "none".PCDATA Script – Specifies the code comprising the procedure.
Example
The following example demonstrates what a "procedure" element might look like. All default values are assumed for optional attributes.
<procedure id="MyProc" context="info"> ~insert script code here </procedure> <procedure id="MyProc" scripttype="eval"> ~insert script code here </procedure>