Difference between revisions of "Context Transitions"

From HLKitWiki
Jump to: navigation, search
(Using "this")
Line 17: Line 17:
 
{{note}}The "this" reference identifies the implied context only. Therefore, you can only use "this" as the first context reference for a target identifier. If "this" is used anywhere else, a compilation error will occur.
 
{{note}}The "this" reference identifies the implied context only. Therefore, you can only use "this" as the first context reference for a target identifier. If "this" is used anywhere else, a compilation error will occur.
  
==Container Context==
+
==Container Context{{anchor|container}}==
  
 
From within a "container" context, you can utilize the following set of valid context transitions:
 
From within a "container" context, you can utilize the following set of valid context transitions:
  
 
:{| class="infotable"
 
:{| class="infotable"
|class="leftnormal"|
+
|class="leftnormal"|state
|
+
|Transitions to the [[#state|''state context'']]. Example: "this.state".
 
|-
 
|-
 
|
 
|
Line 33: Line 33:
 
|}
 
|}
  
==Hero Context==
+
==Hero Context{{anchor|hero}}==
  
 
From within a "hero" context, you can utilize the following set of valid context transitions:
 
From within a "hero" context, you can utilize the following set of valid context transitions:
Line 49: Line 49:
 
|}
 
|}
  
==Pick Context==
+
==Pick Context{{anchor|pick}}==
  
 
From within a "pick" context, you can utilize the following set of valid context transitions:
 
From within a "pick" context, you can utilize the following set of valid context transitions:
Line 65: Line 65:
 
|}
 
|}
  
==Thing Context==
+
==Thing Context{{anchor|thing}}==
  
 
From within a "thing" context, you can utilize the following set of valid context transitions:
 
From within a "thing" context, you can utilize the following set of valid context transitions:
Line 81: Line 81:
 
|}
 
|}
  
==Field Context==
+
==Field Context{{anchor|field}}==
  
 
From within a "field" context, you can utilize the following set of valid context transitions:
 
From within a "field" context, you can utilize the following set of valid context transitions:
Line 97: Line 97:
 
|}
 
|}
  
==Pool Context==
+
==Pool Context{{anchor|pool}}==
  
 
From within a "pool" context, you can utilize the following set of valid context transitions:
 
From within a "pool" context, you can utilize the following set of valid context transitions:
Line 113: Line 113:
 
|}
 
|}
  
==Scene Context==
+
==Scene Context{{anchor|scene}}==
  
 
From within a "scene" context, you can utilize the following set of valid context transitions:
 
From within a "scene" context, you can utilize the following set of valid context transitions:
Line 129: Line 129:
 
|}
 
|}
  
==Layout Context==
+
==Layout Context{{anchor|layout}}==
  
 
From within a "layout" context, you can utilize the following set of valid context transitions:
 
From within a "layout" context, you can utilize the following set of valid context transitions:
Line 145: Line 145:
 
|}
 
|}
  
==Template Context==
+
==Template Context{{anchor|template}}==
  
 
From within a "template" context, you can utilize the following set of valid context transitions:
 
From within a "template" context, you can utilize the following set of valid context transitions:
Line 161: Line 161:
 
|}
 
|}
  
==Portal Context==
+
==Portal Context{{anchor|portal}}==
  
 
From within a "portal" context, you can utilize the following set of valid context transitions:
 
From within a "portal" context, you can utilize the following set of valid context transitions:
Line 177: Line 177:
 
|}
 
|}
  
==Value Context==
+
==Value Context{{anchor|value}}==
  
 
From within a "value" context, you can utilize the following set of valid context transitions:
 
From within a "value" context, you can utilize the following set of valid context transitions:
Line 193: Line 193:
 
|}
 
|}
  
==State Context==
+
==State Context{{anchor|state}}==
  
 
From within a "state" context, you can utilize the following set of valid context transitions:
 
From within a "state" context, you can utilize the following set of valid context transitions:

Revision as of 18:16, 4 December 2008

Context: HL KitKit Reference 

Overview

Every script begins with an initial context that is dictated by the particular script. Quite often, though, you'll want to access information somewhere else within the data hierarchy. That's when context transitions come into play. A context transition allows you to move through the hierarchy, progressing to objects either above or below the current context. These transitions can be chained, allowing you to move through a sequence of contexts to reach the desired destination.

From within a given context, you are only able to transition to a specific set of other contexts. The sections below identify what the valid transitions are for each context.

NOTE! If transitions are utilized that result in an invalid (i.e. non-existent) context, any subsequent target reference will be invalid. If this occurs during run-time, the operation will be ignored and the target identifier will return zero. A suitable error will generally be displayed, but not always. An example of an invalid context is when a pick attempts to transition to a field that does not exist within that pick.

Using "this"

Every script has an initial context that is automatically established (see the specific script to know what it is). Normally, this context is implied, so you don't need to do anything to reference that context. However, some authors will want their scripts to clearly indicate when the implied context is being used. To accommodate this, scripts can utilize the reserved word "this" to indicate the implied context.

For example, an Eval Script starts with the pick as its implied context. So you could write a target identifier that checks the validity of that pick as simply "valid". Alternately, you could specify "this" as the context, yielding a target identifier of "this.valid". Either method is perfectly legal and you are welcome to use whichever method you prefer.

NOTE! The "this" reference identifies the implied context only. Therefore, you can only use "this" as the first context reference for a target identifier. If "this" is used anywhere else, a compilation error will occur.

Container Context

From within a "container" context, you can utilize the following set of valid context transitions:

state Transitions to the state context. Example: "this.state".

Hero Context

From within a "hero" context, you can utilize the following set of valid context transitions:

Pick Context

From within a "pick" context, you can utilize the following set of valid context transitions:

Thing Context

From within a "thing" context, you can utilize the following set of valid context transitions:

Field Context

From within a "field" context, you can utilize the following set of valid context transitions:

Pool Context

From within a "pool" context, you can utilize the following set of valid context transitions:

Scene Context

From within a "scene" context, you can utilize the following set of valid context transitions:

Layout Context

From within a "layout" context, you can utilize the following set of valid context transitions:

Template Context

From within a "template" context, you can utilize the following set of valid context transitions:

Portal Context

From within a "portal" context, you can utilize the following set of valid context transitions:

Value Context

From within a "value" context, you can utilize the following set of valid context transitions:

State Context

From within a "state" context, you can utilize the following set of valid context transitions:

Special Contexts

Within some scripts, special contexts are supported. These special contexts behave the same way within any script that uses them. However, what they correspond to may be different within each script. The specific scripts where special contexts can be used will explicitly cite the availability of the context in their description. Alternately, some special contexts can be established within a script via certain language mechanisms (e.g. "eachpick"). The behavior of these contexts is outlined below.

IMPORTANT! All special contexts must be specified at the start of an identifier. If not, they will not be acknowledged by the compiler. For example, if the "altpick" special context is supported by a script, the reference "altpick.field[livename].text" would work perfectly. However, the reference "this.altpick.field[livename].text" would fail to compile, since "altpick." is not given as the initial context for the identifier.