Adding Items to the Game
|
Now let's add a few items to the game that can be manipulated by the player, so he can do something besides walk back and forth between our two rooms. We'll add a solid gold skull, and a pedestal for it to sit upon.
|
pedestal: Surface, Fixture
|
name = 'pedestal'
|
noun = 'pedestal'
|
location = cave
|
;
|
|
goldSkull: Thing
|
name = 'gold skull'
|
noun = 'skull' 'head'
|
adjective = 'gold'
|
location = pedestal
|
;
|
|
The pedestal belongs to two classes, Surface and Fixture. This means that it has attributes of both classes; when there's a conflict, the Surface class takes precedence, because it's first in the list of classes. Objects of the Surface class can have other objects placed on top of them; objects of the Fixture class can't be carried. The goldSkull belongs to the Thing class, which is the generic class for portable objects without any special properties.
Since these objects can be manipulated directly by the player, the player needs words to refer to them. This is what the noun and adjective properties define. All objects that the player can manipulate must have at least one noun. Note that the goldSkull has two nouns; they are simply listed with a space between them. Objects can also have adjectives; these serve to distinguish between objects which have the same noun, but are otherwise optional. A good game will recognize all of the words it uses to describe an object, so if you describe the skull as a "gold skull," you should understand it when the player says "take the gold skull."
Although here we have defined noun and adjective as separate properties, as indeed they are, the English-language part of the TADS 3 library allows a short cut: we can instead define an object's vocabulary - its nouns and adjectives - in the single property vocabWords, like so:
|
vocabWords = 'gold skull/head'
|
|
These two objects have another new property, location. This simply defines the object that contains the object being defined. In the case of the pedestal, the containing object is the cave room; since the goldSkull is on the pedestal, its location is pedestal. (Note that the system makes no distinction, at this level, between an object being inside another object and the object being on another object. This means that an object can't be both a Surface and a Container.)
Getting Started in TADS 3
[Main]
[Previous] [Next]