1
<HTML><HEAD><TITLE>Section 11: Containers, supporters and sub-objects</TITLE></HEAD>
2
<BODY BGCOLOR="#FFFFFF">
4
<TR><TD Valign="top"><A HREF="contents.html">Contents</A><BR><A HREF="section10.html">Back</A><BR><A HREF="section12.html">Forward</A><TD bgcolor="#F5DEB3"><BLOCKQUOTE><H3>11. Containers, supporters and sub-objects</H3></BLOCKQUOTE><TR><TD><TD>
8
The concept of a surface is implemented as a special kind of containment.
9
Objects which have surfaces on which other objects may sit are actually
10
containers with an additional property of "surfaceness".
11
<P>...P. David Lebling, <I>Zork and the Future</I></BLOCKQUOTE>
15
The year has been a good one for the Society <I> (hear, hear)</I>.
16
This year our members have put more things on top of other things
17
than ever before. But, I should warn you, this is no time for
18
complacency. No, there are still many things, and I cannot
19
emphasize this too strongly, <I> not</I> on top of other things.
20
<P>...'The Royal Society For Putting Things On Top Of
21
Other Things', <I> Monty Python's Flying Circus</I>,
22
programme <B>18</B> (<B>1970</B>)</BLOCKQUOTE>
27
Objects can be inside or on top of one another. An object which has the
28
<TT>container</TT> attribute can contain things, like a box: one which has
29
<TT>supporter</TT> can hold them up, like a table. (An object can't have both at
30
once.) It can hold up to 100 items, by default: this is set by the <TT>capacity</TT>
32
However, one can only put things inside a container when it has <TT>open</TT>.
33
If it has <TT>openable</TT>, the player can open and close it at will, unless
34
it also has <TT>locked</TT>. A <TT>locked</TT> object (whether it be a door or a
35
container) cannot be opened. But if it has <TT>lockable</TT> then it can be
36
locked or unlocked with the key object given in the <TT>with_key</TT> property.
37
If <TT>with_key</TT> is undeclared, then no key will fit, but this will not be told
38
to the player, who can try as many as he likes.
41
Containers (and supporters) are able to react to things being put inside
42
them, or removed from them, by acting on the signal to <TT>Receive</TT> or
43
<TT>LetGo</TT>. For example, deep under the 'Ruins' is a chasm which,
44
perhaps surprisingly, is implemented as a container:
46
Object -> chasm "horrifying chasm"
47
with name "blackness" "chasm" "pit" "depths" "horrifying" "bottomless",
49
[; Jump: <<Enter self>>;
50
Go: if (noun==d_obj) <<Enter self>>;
54
"You plummet through the silent void of darkness!";
57
[; Receive: remove noun;
58
print_ret (The) noun, " tumbles silently into the
59
darkness of the chasm.";
60
Search: "The chasm is deep and murky.";
62
has scenery open container;
65
(Actually the definition is a little longer, so that the chasm reacts to a
66
huge pumice-stone ball being rolled into it; see 'Ruins'.) Note the use of
67
an <TT>after</TT> rule for the <TT>Search</TT> action: this is because an attempt to
68
"examine'' or "look inside'' the chasm will cause this action.
69
<TT>Search</TT> means, in effect, "tell me what is inside the container'' and the
70
<TT>after</TT> rule prevents a message like "There is nothing inside the chasm.''
71
from misleading the player. Note also that the chasm 'steals' any stray
72
<TT>Jump</TT> action and converts it into an early death.
75
<P><TR><TD Valign="top"><IMG SRC="icons/exercise.gif" ALT="??"><TD bgcolor="#FBB9AC"><A NAME="ex9"><B>EXERCISE 9:</B><BR>(link to <A HREF="answers1/answer9.html">the answer</A>)<TR><TD><TD> Make the following, rather acquisitive bag:
78
The bag wriggles hideously as it swallows the fish.
80
The bag defiantly bites itself shut on your hand until you desist.
85
<P><TR><TD Valign="top"><IMG SRC="icons/dbend.gif" ALT="/\"><TD bgcolor="#EEEEEE"><SMALL> <TT>LetGo</TT> and <TT>Receive</TT> are examples of actions which aren't
86
explicitly requested by the player, but are generated by the game in the
87
course of play (so-called "fake actions'').
91
<P><TR><TD Valign="top"><IMG SRC="icons/dbend.gif" ALT="/\"><TD bgcolor="#EEEEEE"><SMALL> <TT>Receive</TT> is sent to an object <I>O</I> both when a player tries to put
92
something in <I>O</I>, and put something on <I>O</I>. In the rare event that <I>O</I>
93
needs to react differently to these, it may consult the variable
94
<TT>receive_action</TT> to find out whether <TT>##PutOn</TT> or <TT>##Insert</TT> is the
100
The 'Ruins' packing case is a typical container:
102
Object -> packing_case "packing case"
103
with name "packing" "case" "box" "strongbox",
105
"Your packing case rests here, ready to hold any important
106
cultural finds you might make, for shipping back to civilisation.",
108
[; Take, Remove, PushDir:
109
"The case is too heavy to bother moving, as long as your
110
expedition is still incomplete.";
112
has static container open;
118
Now suppose we want a portable television set with four different
119
buttons on it. Obviously, when the television moves, its buttons
120
should move with it, and the sensible way to arrange this is to make the
121
four buttons possessions of the <TT>television</TT> object. But members of
122
an object which isn't a container are normally assumed by the game to
123
be hidden invisibly inside (they are said to be "not in scope''). We
124
have to override this in order to make the four buttons visible from
125
outside, by giving the television the <TT>transparent</TT> attribute.
128
<P><TR><TD Valign="top"><IMG SRC="icons/exercise.gif" ALT="??"><TD bgcolor="#FBB9AC"><A NAME="ex10"><B>EXERCISE 10:</B><BR>(link to <A HREF="answers1/answer10.html">the answer</A>)<TR><TD><TD> Implement a television set with attached power button and
132
<P><TR><TD Valign="top"><IMG SRC="icons/exercise.gif" ALT="??"><TD bgcolor="#FBB9AC"><A NAME="ex11"><B>EXERCISE 11:</B><BR>(link to <A HREF="answers1/answer11.html">the answer</A>)<TR><TD><TD> Make a glass box and a steel box, which would behave
133
differently when a lamp is shut up inside
137
<P><TR><TD Valign="top"><IMG SRC="icons/dbend.gif" ALT="/\"><TD bgcolor="#EEEEEE"><SMALL> It sometimes happens that an object should have sub-objects,
138
like lamps and buttons, as well as possessions, in which case the
139
above solution is unsatisfactory. Fuller details will be given in the
140
"scope addition'' rules in <A HREF="section28.html">Section 28</A>, but briefly: an
141
object's <TT>add_to_scope</TT> property may contain a list of sub-objects
142
to be kept attached to it (and these sub-objects don't count as
147
<P><TR><TD Valign="top"><IMG SRC="icons/exercise.gif" ALT="??"><TD bgcolor="#FBB9AC"><A NAME="ex12"><B>EXERCISE 12:</B><BR>(link to <A HREF="answers1/answer12.html">the answer</A>)<TR><TD><TD> Implement a macramè bag hanging from the ceiling, inside
148
which objects are visible (and audible, etc.) but cannot be touched or
149
manipulated in any way.
152
<P><TR><TD Valign="top"><IMG SRC="icons/refs.gif" ALT="*"><TD bgcolor="#EEEEEE"><B>REFERENCES:</B><BR><SMALL> Containers and supporters abound in the example games
153
(except 'Advent', which is too simple, though see the
154
water-and-oil carrying bottle). Interesting containers include
155
the lottery-board and the podium sockets from 'Balances' and
156
the 'Adventureland' bottle.
158
For supporters, the hearth-rug, chessboard, armchair and mantelpiece
159
of 'Alice Through The Looking-Glass' are typical examples; the
160
mantelpiece and spirit level of 'Toyshop' make a simple puzzle,
161
and the pile of building blocks a complicated one; see also the
162
scales in 'Balances'.
164
<HR><A HREF="contents.html">Contents</A> / <A HREF="section10.html">Back</A> / <A HREF="section12.html">Forward</A> <BR>
165
<A HREF="chapter1.html">Chapter I</A> / <A HREF="chapter2.html">Chapter II</A> / <A HREF="chapter3.html">Chapter III</A> / <A HREF="chapter4.html">Chapter IV</A> / <A HREF="chapter5.html">Chapter V</A> / <A HREF="chapter6.html">Chapter VI</A> / <A HREF="chapterA.html">Appendix</A><HR><SMALL><I>Mechanically translated to HTML from third edition as revised 16 May 1997. Copyright © Graham Nelson 1993, 1994, 1995, 1996, 1997: all rights reserved.</I></SMALL></BODY></HTML>