ScriptMacro Element (Data): Difference between revisions

From HLKitWiki
Jump to navigationJump to search
No edit summary
No edit summary
 
Line 3: Line 3:
==The "scriptmacro" Element==
==The "scriptmacro" Element==


Each phase within the [[Evaluation Cycle Basics|evaluation cycle]] must be individually specified and the sequence in which the phase elements are defined dictates the sequence in which phases are processed during evaluation. The XML element name is "phase" and the complete list of attributes is below.
The "scriptmacro" element defines a [[Employing Script Macros|macro for use within the scripting language]] to conveniently access object details. Each macro specifies a kind of shorthand notation for a lengthy block of script code that can be used in place of the full code and will be treated as if the full code were entered. Script macros are globally defined and may be used within any script. The complete list of attributes for a "scriptmacro" element is below.  


:{| class="infotable"
:{| class="infotable"
|class="leftnormal"|id
|class="leftnormal"|name
|Id Specifies the unique id assigned to this phase. This id is used to reference the phase throughout the data files.
|Text Name to be used for the macro. May consist solely of alphanumeric characters.
|-
|-
|name
|result
|Text – Common name for the phase is displayed in various situations. Maximum length is 25 characters.
|Text – The resulting text to be generated when the macro is used. Each parameter is spliced into the result appropriately.
|-
|-
|description
|param1
|(Optional) Text – Textual description of the role the phase serves within the game system. Default: Empty.
|(Optional) Text – Name used for the first parameter provided to macro. Used for splicing the value into the "result" given above.
|-
|-
|interleave
|param2
|(Optional) Boolean Indicates whether all tasks within this phase are either (a) interleaved across [[Minion and Master Relationships|masters and minions]] or (b) processed hierarchically, with masters always being evaluated before minions. This works the exact same way as the "interleave" attribute within [[Behavior Element (Data)|the "behavior" element]], except that it only applies to tasks within this specific phase. Default: "yes".
|(Optional) Text Name used for the second parameter provided to macro. Used for splicing the value into the "result" given above.
{{important}}This attribute is only applicable when interleaving is '''enabled''' for the game system. It provides a means of forcing individual phases to be non-interleaved, which makes it possible to safely control dependencies of minions upon their masters for enablement conditions and the like. The default is "yes" so that all phases are interleaved by default if the game system behavior is designated as interleaved.
|-
|param3
|(Optional) Text – Name used for the third parameter provided to macro. Used for splicing the value into the "result" given above.
|-
|param4
|(Optional) Text – Name used for the fourth parameter provided to macro. Used for splicing the value into the "result" given above.
|-
|param5
|(Optional) Text – Name used for the fifth parameter provided to macro. Used for splicing the value into the "result" given above.
|-
|-
|}
|}
Line 23: Line 31:
==Example==
==Example==


The following example demonstrates what a "phase" element might look like. All default values are assumed for omitted optional attributes.
The following example demonstrates what a "scriptmacro" element might look like. All default values are assumed for omitted optional attributes.


<pre>
<pre>
<phase
<scriptmacro
   id="Initialize"
   name="trait"
   name="Initialization"
   param1="trait"
   description="Anything that has to happen before everything else">
   result="hero.child[#trait].field[trtFinal].value">
   </phase>
   </scriptmacro>
</pre>
</pre>
  <scriptmacro name="trait" param1="trait" result="hero.child[#trait].field[trtFinal].value"/>

Latest revision as of 02:01, 9 December 2008

Context: HL Kit &#133; Kit Reference &#133; Definition File Reference 

The "scriptmacro" Element

The "scriptmacro" element defines a macro for use within the scripting language to conveniently access object details. Each macro specifies a kind of shorthand notation for a lengthy block of script code that can be used in place of the full code and will be treated as if the full code were entered. Script macros are globally defined and may be used within any script. The complete list of attributes for a "scriptmacro" element is below.

name Text – Name to be used for the macro. May consist solely of alphanumeric characters.
result Text – The resulting text to be generated when the macro is used. Each parameter is spliced into the result appropriately.
param1 (Optional) Text – Name used for the first parameter provided to macro. Used for splicing the value into the "result" given above.
param2 (Optional) Text – Name used for the second parameter provided to macro. Used for splicing the value into the "result" given above.
param3 (Optional) Text – Name used for the third parameter provided to macro. Used for splicing the value into the "result" given above.
param4 (Optional) Text – Name used for the fourth parameter provided to macro. Used for splicing the value into the "result" given above.
param5 (Optional) Text – Name used for the fifth parameter provided to macro. Used for splicing the value into the "result" given above.

Example

The following example demonstrates what a "scriptmacro" element might look like. All default values are assumed for omitted optional attributes.

<scriptmacro
  name="trait"
  param1="trait"
  result="hero.child[#trait].field[trtFinal].value">
  </scriptmacro>