Chosen Script: Difference between revisions

From HLKitWiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 12: Line 12:
|Fields Finalized?
|Fields Finalized?
|Yes
|Yes
|-
|Where Used:
|[[Portal Element (Data)|Portals]]
|-
|-
|}
|}

Revision as of 00:16, 16 December 2008

Context: HL Kit … Kit Reference … Script Types 

Technical Details

Initial Context: Pick
Alternate Context: None
Fields Finalized? Yes
Where Used: Portals

The Chosen script utilizes the following special symbols:

text (String) Entry: Contains the default text to display ("-Please Select-").

Exit: Contains the text to be displayed to the user as the chosen selection. The final text may contain encoding.

ispick (Number) Entry: Indicates whether the chooser contains a selection or not.

Exit: Ignored.

Description

The Chosen script is essentially a special-purpose Label script used in conjunction with choosers. This script allows you to synthesize the text to be displayed as the current selection within a chooser. If nothing has been selected yet, you can prompt the user to do so, and you can use color-coding to indicate errors with the current selection.

The initial context for the script is the currently selected item. If nothing is selected, the initial context with be invalid, so you're limited to displaying something simple. Aside from that, the Chosen script is a standard Label script.

NOTE!  The Chosen script is read-only. Within this script, virtually all aspects of the structural hierarchy can be accessed, but nothing can be changed.

Example

Choosers provide an excellent solution when the user must choose exactly one option from an assortment. An excellent example is race, where a character must be assigned a single race. The code below shows the Chosen script for the race chooser within the Skeleton files, including color highlighting when no selection has yet been made.

if (@ispick = 0) then
  @text = "{text ff0000}Select Race"
else
  @text = "Race: " & field[name].text
  endif