AddItem Script

From HLKitWiki
Revision as of 08:54, 20 February 2009 by Rob (talk | contribs) (→‎Technical Details)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Context: HL Kit … Kit Reference … Script Types 

Technical Details

Initial Context: Pick
Alternate Context: None
Fields Finalized? Yes
Where Used: Portals
Procedure Use: "label" type, "info" context, "pick" context

The AddItem script utilizes the following special symbols:

text (String) Entry: Contains the empty string.

Exit: Contains the text to be displayed to the user as the "add" item at the bottom of the table. The final text may contain encoding.

Description

The AddItem script is essentially a special-purpose Label script used in conjunction with tables. This script allows you to synthesize the text to be displayed within a simple "add item" at the bottom of a table, without all the work of defining a custom template. The "add item" for a table enables the user to click within it to add a new item to the table.

The initial context for the script is dictated by the "addpick" attribute for the table. The engine will locate a pick within the container that is derived from the specified thing, and that will be the starting script context. Aside from that, the AddItem script is a standard Label script.

The simple "add item" provided via the mechanism displays a single line of text, centered within the item at the bottom of the table. The text is centered within the item and defaults to using a 10-point Arial font in soft white with a bold style.

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

Example

The Skeleton files make extensive use of this mechanism for putting a tailored item at the bottom of each table that prompts the user to add the appropriate kind of object. You can also color-code the text to indicate whether items need to be added or too many items have been added. For example, at the bottom of the table for selecting Special Abilities, the "add item" shows an appropriate message and highlights it based on how many selections remain.

~set the color based on whether the proper number of slots are allocated
if (field[resLeft].value = 0) then
  @text = "{text a0a0a0}"
elseif (field[resLeft].value < 0) then
  @text = "{text ff0000}"
  endif
@text &= "Add New Special Ability"