ThingStateclassthing.t[471], en_us.t[175]

"State" of a Thing. This is an object abstractly describing the state of an object that can assume different states.

The 'listName', 'inventoryName', and 'wornName' give the names of state as displayed in room/contents listings, inventory listings, and listings of items being worn by an actor. This state name is displayed along with the item name (usually parenthetically after the item name, but the exact nature of the display is controlled by the language-specific part of the library).

The 'listingOrder' is an integer giving the listing order of this state relative to other states of the same kind of object. When we show a list of equivalent items in different states, we'll order the state names in ascending order of listingOrder.

Modified in en_us.t[175]:
Language-specific modifications for ThingState.

class ThingState :   object

Superclass Tree   (in declaration order)

ThingState
        object

Subclass Tree  

(none)

Global Objects  

lightSourceStateOff  lightSourceStateOn  matchStateLit  matchStateUnlit  unwornState  wornState 

Summary of Properties  

listingOrder  listName_  stateTokens 

Summary of Methods  

findStateToken  inventoryName  listName  matchName  wornName 

Properties  

listingOrderthing.t[504]

the relative listing order

listName_en_us.t[267]
our list name setting - we define this so that we can be easily initialized with a template (we can't initialize listName() directly in this manner because it's a method, but we define the listName() method to simply return this property value, which we can initialize with a template)

stateTokensen_us.t[188]
Our state-specific tokens. This is a list of words that can be used in noun phrases in parsed input to refer to this state, and ONLY to this state - that it, these words must not refer to any other states among the possible states for an object that can take on this state.

If a noun phrase contains a word from this list, it means that the noun phrase CAN refer to an object in this state, and that the noun phrase CANNOT refer to an object in any other state that is possible for objects that can assume this state.

Methods  

findStateToken (toks)en_us.t[235]

Check a token list for any tokens matching any of our state-specific words. Returns true if we find any such words, nil if not.

'toks' is the *adjusted* token list used in matchName().

inventoryName (lst)thing.t[494]
The state name to use in inventory lists. By default, we just use the base name. 'lst' has the same meaning as in listName().

listName (lst)thing.t[488], en_us.t[258]
The name of the state to use in ordinary room/object contents listings. If the name is nil, no extra state information is shown in a listing for an object in this state. (It's often desirable to leave the most ordinary state an object can be in unnamed, to avoid belaboring the obvious. For example, a match that isn't burning would probably not want to mention "(not lit)" every time it's listed.)

'lst' is a list of the objects being listed in this state. If we're only listing a single object, this will be a list with one element giving the object being listed. If we're listing a counted set of equivalent items all in this same state, this will be the list of items. Everything in 'lst' will be equivalent (in the isEquivalent sense).

Modified in en_us.t[258]:
get our name

matchName (obj, origTokens, adjustedTokens, states)thing.t[520], en_us.t[196]
Match the name of an object in this state. 'obj' is the object to be matched; 'origTokens' and 'adjustedTokens' have the same meanings they do for Thing.matchName; and 'states' is a list of all of the possible states the object can assume.

Implementation of this is always language-specific. In most cases, this should do something along the lines of checking for the presence (in the token list) of words that only apply to other states, rejecting the match if any such words are found. For example, the ThingState object representing the unlit state of a light source might check for the presence of 'lit' as an adjective, and reject the object if it's found.

Modified in en_us.t[196]:
Match the name of an object in this state. We'll check the token list for any words that apply only to *other* states the object can assume; if we find any, we'll reject the match, since the phrase must be referring to an object in a different state.

wornName (lst)thing.t[501]
The state name to use in listings of items being worn. By default, we just use the base name. 'lst' has the same meaning as in listName().

TADS 3 Library Manual
Generated on 9/8/2006 from TADS version 3.0.11