PreCond
|
There are certain necessary conditions that tend to recur commonly in IF actions. In order to read the book or examine the chest, the objects in question have to be visible. In order to hit the troll with the sword, or move the nest with the stick, or unlock the chest with the gold key, the sword, stick or key first have to be held. These common conditions are encapsulated in TADS 3 as PreCondition objects, since they represent the common preconditions of various types of a command.
The preCond property in dobjFor or iobjFor propertyset contains (or, if it is a routine, returns) a list of the preconditions needed for the object in question to be used in the action in question. For example, in the case of reading the book and examining the chest you might define:
|
preCond = [objVisible]
|
|
|
preCond = [objHeld]
|
|
|
dobjFor(Read)
|
{
|
preCond = [objVisible, objHeld]
|
|
}
|
|
The library defines several preconditions, including objOpen, objClosed, objUnlocked, touchObj, actorStanding, objAudible. For a complete list, see the pre-conditions section of the "TADS 3 Action Results" section of the Technical Manual. It is also perfectly possible (and often useful) to define your own, although that is beyond the scope of this guide. The best way to get a full understanding of preconditions is to study the library file precond.t.
Getting Started in TADS 3
[Main]
[Previous] [Next]