scenery
attribute.
Object Crypt "Crypt" with description "You are in a gloomy crypt. Everything is stylishly gothic, particularly the life-size cardboard cutout of Spike which dominates the ambience.", has light; Object -> cutout "cutout" with name 'cutout', has scenery; |
Crypt You are in a gloomy crypt. Everything is stylishly gothic, particularly the life-size cardboard cutout of Spike which dominates the ambience. |
But what if you want the object to be portable? A scenery
object can't be picked up.
describe
property which does nothing but return
true.
(You can't use the initial
property for this purpose,
because the library prints its own blank line before calling
initial
. You'd wind up with two blank lines in a row,
which is ugly.)
But of course you have to adjust both the room description and the
object's describe
property, to account for both cases:
when the object is present in the room, and when it isn't.
Object Crypt "Crypt" with description [; print "You are in a gloomy crypt. Everything is stylishly gothic"; if (cutout in self) print ", particularly the life-size cardboard cutout of Spike which dominates the ambience"; "."; ], has light; Object -> cutout "cutout" with name 'cutout', describe [; if (self in Crypt) rtrue; ]; |
Crypt You are in a gloomy crypt. Everything is stylishly gothic, particularly the life-size cardboard cutout of Spike which dominates the ambience. >get cutout Taken. >look Crypt You are in a gloomy crypt. Everything is stylishly gothic. >drop cutout Dropped. >look Crypt You are in a gloomy crypt. Everything is stylishly gothic, particularly the life-size cardboard cutout of Spike which dominates the ambience. |
Note that if the cutout is not in the Crypt, its
describe
does nothing and returns false. This allows it
to show up in object lists in the usual way.
The initial
property is perfectly suited for this, if you
don't mind the object's special listing appearing in its own
paragraph, after the room description. But if you want them to be
integrated, you have to use describe
again. This time, we
check the moved
attribute, instead of the object's
location. (The library automatically sets moved
whenever
an object is carried by the player.)
Object Crypt "Crypt" with description [; print "You are in a gloomy crypt. Everything is stylishly gothic"; if (portrait hasnt moved) print ", particularly the portrait of LaCroix on the wall"; "."; ], has light; Object -> portrait "portrait" with name 'portrait', describe [; if (self hasnt moved) rtrue; ], after [; Take: if (self hasnt moved) "You take the portrait down from the wall."; ]; |
Note that we've also thrown in an after
clause, so
that the first "take" command produces a special message.
Crypt You are in a gloomy crypt. Everything is stylishly gothic, particularly the portrait of LaCroix on the wall. >get portrait You take the portrait down from the wall. >look Crypt You are in a gloomy crypt. Everything is stylishly gothic. >drop portrait Dropped. >look Crypt You are in a gloomy crypt. Everything is stylishly gothic. You can see a portrait here. |
describe
trick won't work for an object which is on
a table (or other supporter).
One simple gimmick is to not put the object on the table at all! Give it
an initial
message which says that it's on the
table. When the player picks it up, the initial
message
will stop appearing, which is consistent. Unless the table moves to
other rooms, the player won't see any real difference.
Object Crypt "Crypt" with description "You are in a gloomy crypt. Everything is stylishly gothic.", has light; Object -> table "table" with name 'table', initial "A table stands in the center of the room.", before [; Examine: <<Search self>>; Search: if (statuette hasnt moved) { print "Resting on the table is a salt statuette of Nancy Crater"; if (~~child(self)) "."; print ". Beside the statuette"; WriteListFrom(child(self), TERSE_BIT + ENGLISH_BIT + ISARE_BIT); "."; } ], has supporter static; Object -> statuette "statuette" with name 'statuette', initial "A glittering salt statuette of Nancy Crater rests on the table."; |
It is nice, for this trick, to customize the table's "search" command. The statuette appears there if it hasn't been moved (whether the table is "really" empty or not.) Once the statuette has been moved, the table defaults to standard "search" routine, which lists all objects (possibly including the moved statuette).
For bonus points, we make the "examine" command synonymous with "search", since there isn't much of interest to the table besides its contents.
Crypt You are in a gloomy crypt. Everything is stylishly gothic. A table stands in the center of the room. A glittering salt statuette of Nancy Crater rests on the table. >search table Resting on the table is a salt statuette of Nancy Crater. >put wand on table You put the wand on the table. >look Crypt You are in a gloomy crypt. Everything is stylishly gothic. A table stands in the center of the room. On the table is a wand. A glittering salt statuette of Nancy Crater rests on the table. >search table Resting on the table is a salt statuette of Nancy Crater. Beside the statuette is a wand. >get statuette Taken. >search table On the table is a wand. >put statuette on table You put the statuette on the table. >look Crypt You are in a gloomy crypt. Everything is stylishly gothic. A table stands in the center of the room. On the table are a statuette and a wand. >search table On the table are a statuette and a wand. |
WriteListFrom()
, and use the WORKFLAG_BIT
feature to list everything except the statuette.