State Context: Difference between revisions

From HLKitWiki
Jump to navigationJump to search
 
Line 10: Line 10:


:{| class="infotable"
:{| class="infotable"
|class="leftnormal"|-None-
|class="leftnormal"|thing[''id'']
|There are no transitions from within a state context.
|Transitions to the [[Thing Context|thing context]] corresponding to the thing with the ''id'' specified. If no thing exists with the given unique id, an error is reported.<br>
Example: this.thing[myid]
|-
|-
|}
|}

Latest revision as of 09:25, 12 May 2009

Context: HL Kit &#133; Kit Reference  &#133; Multiple Sources

Jump to: Target References

The "state" context provides access to overall state information that pertains to the portfolio as a whole or general information about the evaluation cycle.

Context Transitions

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

thing[id] Transitions to the thing context corresponding to the thing with the id specified. If no thing exists with the given unique id, an error is reported.

Example: this.thing[myid]

Target References

The "state" context is a general context that maintains information outside the normal data hierarchy. The target references for this context span a wide range of details that may prove useful within your scripts. The complete list of target references for the "state" context is presented in the table below.

isfocus (Right, Number) Returns non-zero if a focus pick has been properly established via the "setfocus" target reference.

Example: result = state.isfocus

clearfocus (Right, Number) Clears any focus pick that has been established and resets to a state where there is no focus pick.

Example: perform state.clearfocus

timing (Right, String) Returns the phase and priority timing during which the current script is being invoked in an effort to simplify debugging of data files.

Example: result = state.timing

iscreate (Right, Number) Returns non-zero if the character is currently in creation mode.

Example: result = state.iscreate

isadvance (Right, Number) Returns non-zero if the character is currently in advancement mode.

Example: result = state.isadvance

issell (Right, Number) Returns non-zero if the user is currently in the midst of a sell transaction.

Example: result = state.issell

isload (Right, Number) Returns non-zero if the loading of a saved portfolio is currently in progress.

Example: result = state.isload

isoutput (Right, Number) Returns non-zero if the rendering of character sheet output is currently in progress.

Example: result = state.isoutput

isdossierstyle[style] (Right, Number) Returns whether the user selected text output to be formatted in the style given by the style parameter. The style parameter must be one of the following values: "plain", "html", or "bbcode".

Example: result = state.isdossierstyle[html]

istext (Right, Number) Returns non-zero if the render of text output is currently in progress.

Example: result = state.istext

iscombat (Right, Number) Returns non-zero if combat mode is currently enabled within the Tactical Console.

Example: result = state.iscombat

isendturn (Right, Number) Returns non-zero if all combatants have taken their allotted actions and it is valid to end the current combat turn.

Example: result = state.isendturn

combatturn (Right, Number) Returns the current combat turn that is underway within the Tactical Console.

Example: result = state.combatturn

initchange (Right, Number) Returns non-zero if any actor has a user-modified initiative value.

Example: result = state.initchange

actorcount (Right, Number) Returns the total number of actors within the portfolio, including all minions.

Example: result = state.actorcount

reload[table] (Right, Number) Forces a re-load and re-sort of the table portal whose id is given by the table parameter. This target reference is only accessible from within a Trigger Script.

Example: result = state.reload[myportal]

value[id] (Left, Right, Number) Provides direct access (read/write) to a global value with the given id. This value is globally defined, outside the scope of any actors, and it is persistent. The state of all global values is saved with the portfolio and restored on a reload. A global value must be set before it is retrieved, else a run-time error is reported.

Example: result = state.value[id]
NOTE! This mechanism makes it possible to manage state across the entire portfolio.

setrandom[id,cnt] (Right, Number) Creates a new set of random values with the given id. The set contains the integer values zero through cnt-1, with the values being in a random sequence. The set of values is globally defined, outside the scope of any actors, and it is persistent. The state of the set will be saved with the portfolio and restored on a reload. The value returned is always zero.

Example: result = state.setrandom[setid,42]
NOTE! This mechanism makes it possible to simulate set-based behaviors, such as a deck of cards. The other target references beginning with the "set" prefix below are used in conjunction with this set.

setextract[id] (Right, Number) Extracts and returns the next value from the set with the given id, which must already be created. If there are no values left within the set, a run-time error is reported and the value zero is returned.

Example: result = state.setextract[setid]

setremain[id] (Right, Number) Returns the number of values that remain within the set with the given id.

Example: result = state.setremain[setid]

setdiscard[id,val] (Right, Number) Locates the value val within the set with the given id and discards it from the set. Once discarded, the set behaves as if the value no longer exists within the set.

Example: result = state.setdiscard[setid,42]