Thing Target References

From HLKitWiki
Jump to: navigation, search

Context: HL KitKit Reference … Target References 

See Also: Thing Context Transitions

There are a number of target references that apply to things that have not been added to a container. These come into play at times like testing pre-requisites and when things are selected via menus. While similar to picks in many ways, things have no dynamic facets and are therefore always read-only in behavior. The complete list of target references for thing is presented in the table below.

idstring (Right, String) Returns the unique id of the thing as a string. This can be extremely handy when synthesizing tag templates and tag expressions on-the-fly via scripts.

Example: result = this.idstring

ispick (Right, Number) Returns non-zero if the current context is a pick and zero if it's a thing. This provides a means to discern the nature of the context when the circumstances make a distinction uncertain, such as within procedures.

Example: result = this.ispick

isunique (Right, Number) Returns non-zero if the thing behaves as unique.

Example: result = this.isunique

tagis[tmpl] (Right, Number) Returns non-zero if any tags assigned to the thing match the tag template tmpl, else zero if no tags match. The template must use the standard "group.id" syntax and may contain a wildcard.

Example: this.tagis[skill.?]

tagcount[tmpl] (Right, Number) Returns the number of tags assigned to the thing that match the tag template tmpl. The template must use the standard "group.id" syntax and may contain a wildcard.

Example: result = this.tagcount[skill.?]

tagvalue[tmpl] (Right, Number) Returns the value of a tag assigned to the thing that matches the tag template tmpl. The rules associated with tag values in tag expressions apply. The template must use the standard "group.id" syntax and may contain a wildcard.

Example: result = this.tagvalue[spelllevel.wizard?]

tagmin[tmpl] (Right, Number) Returns the minimum value of all tags assigned to the thing that match the tag template tmpl. The rules associated with tag values in tag expressions apply. The template must use the standard "group.id" syntax and may contain a wildcard.

Example: result = this.tagmin[spelllevel.wizard?]

tagmax[tmpl] (Right, Number) Returns the maximum value of all tags assigned to the thing that match the tag template tmpl. The rules associated with tag values in tag expressions apply. The template must use the standard "group.id" syntax and may contain a wildcard.

Example: result = this.tagmax[spelllevel.wizard?]

tagunique[tmpl] (Right, Number) Returns the number of unique tags assigned to the thing that match the tag template tmpl. If a tag is assigned multiple times, it is only counted once. The template must use the standard "group.id" syntax and may contain a wildcard.

Example: result = this.tagunique[skill.?]

tagexpr[expr] (Right, Number) Returns non-zero if the tags assigned to the thing match the tag expression expr, else zero is returned. The expr parameter must be a valid tag expression.

Example: result = this.tagexpr[class.wizard & (val:spelllevel.wizard? > 5)]

tagcountstr[str] (Right, Number) This target reference is identical to "tagcount", except that the str parameter is a string expression that is evaluated within the script. This allows the tag template to be dynamically determined via the script instead of being hard-wired at compilation.

Example: result = this.tagcountstr["skill.?"]

tagvaluestr[str] (Right, Number) This target reference is identical to "tagvalue", except that the str parameter is a string expression that is evaluated within the script. This allows the tag template to be dynamically determined via the script instead of being hard-wired at compilation.

Example: result = this.tagvaluestr["spelllevel.wizard?"]

tagminstr[str] (Right, Number) This target reference is identical to "tagmin", except that the str parameter is a string expression that is evaluated within the script. This allows the tag template to be dynamically determined via the script instead of being hard-wired at compilation.

Example: result = this.tagminstr["spelllevel.wizard?"]

tagmaxstr[str] (Right, Number) This target reference is identical to "tagmax", except that the str parameter is a string expression that is evaluated within the script. This allows the tag template to be dynamically determined via the script instead of being hard-wired at compilation.

Example: result = this.tagmaxstr["spelllevel.wizard?"]

taguniquestr[str] (Right, Number) This target reference is identical to "tagunique", except that the str parameter is a string expression that is evaluated within the script. This allows the tag template to be dynamically determined via the script instead of being hard-wired at compilation.

Example: result = this.taguniquestr["skill.?"]

tagsearch[str] (Right, Number) This target reference is identical to "tagexpr", except that the str parameter is a string expression that is evaluated within the script. This allows the tag expression to be dynamically determined via the script instead of being hard-wired at compilation.

Example: result = this.tagsearch["class.wizard & (val:spelllevel.wizard? > 5)"]
NOTE! Using "tagsearch" is MUCH slower in performance than using "tagexpr", since the tagexpr must be parsed and compiled every time the script is evaluated. Be sure to use "tagexpr" whenever possible.

tagmatch[refgrp,match,ref] (Right, Number) Returns non-zero if any tags within a reference context also exist within a match context, else zero. This allows tags from one context to be verified to exist within another context, making tag-based comparisons between two objects possible. For more details, please check here.

Example: result = hero.tagmatch[NeedStatus,HasStatus,initial]

intersect[curr,init] (Right, Number) Returns non-zero if tags within the initial script context also exist within the currently transitioned context, else zero. All of the tags that belong to the init tag group within the initial script context are compared against the tags that belong to the curr tag group within the current context. If any of those tags possess the identical tag id, then a match is returned (i.e. non-zero). The same tag group may be used for both contexts, and both contexts must be objects that possess tags (i.e. container, pick, or thing).

Example: result = this.intersect[MyGroup,AltGroup]

tagnames[tmpl,spl] (Right, String) Generates and returns a list of tags within the thing. Only tags that match the tag template tmpl are included in the list. The generated string appends the names of the tags together, inserting the splicing string spl between each name if there is more than one. A thing with no tags matching the template will return the empty string.

Example: result = this.tagnames[Weapon.?,"+"]

tagabbrevs[tmpl,spl] (Right, String) Works identically to "tagnames", except that the generated string is comprised of the abbreviations for all matching tags instead of their names.

Example: result = this.tagabbrevs[Weapon.?,"+"]

tagids[tmpl,spl] (Right, String) Works identically to "tagnames", except that the generated string is comprised of the unique ids for all matching tags instead of their names.

Example: result = this.tagids[Weapon.?,"+"]

prereqok (Right, Number) Returns non-zero if the pick satisfies all of its pre-requisites. May not be used during evaluation.

Example: result = this.prereqok

prereqnum (Right, Number) Returns the total number of pre-requisite rules that exist for the current pick. May not be used during evaluation.

Example: result = this.prereqnum

prereqmsg[index] (Right, String) Returns the message associated with a specific pre-requisite test for the current pick, where the desired test is given by index. The index is zero-based, so the values 0 through 4 should be used for a pick with 5 pre-requisites. If the individual pre-requisite is satisfied, the text returned is the empty string. Otherwise, the text returned is the corresponding message. May not be used during evaluation.

Example: result = this.prereqmsg[i]
NOTE! Retrieving the message for individual pre-requisite tests will trigger a re-calculation every time, so it is expensive and should only be used sparingly.

isgear (Right, Number) Returns non-zero if the thing is a piece of gear.

Example: result = this.isgear

isholdable (Right, Number) Returns non-zero if the pick is gear that can be placed into a gear holder.

Example: result = this.isholdable

stackable (Right, Number) Returns non-zero if the thing can be stacked with other equivalent picks.

Example: result = this.stackable

isbootstrap[thing] (Right, Number) Returns non-zero if the current thing directly bootstraps a thing with the specified id thing.

Example: result = this.isbootstrap[thingid]

islinkage[link] (Right, Number) Returns non-zero if the current thing possesses a linkage with the specified id link.

Example: result = this.islinkage[linkid]

ispanel (Right, Number) Returns non-zero if the thing has a panel linkage defined for it. This allows generic handling of panel linkages within component scripts when the actual panel linkage is optionally controlled by the thing.

Example: result = this.ispanel

sourcerefs[spl] (Right, String) Generates and returns a list of all sources that the current thing is dependent upon. The generated string appends the names of the sources together, inserting the splicing string spl between each name if there is more than one. A thing with no source dependencies will return the empty string.

Example: result = this.sourcerefs["+"]