~ubuntu-branches/ubuntu/gutsy/inform/gutsy

« back to all changes in this revision

Viewing changes to html/section10.html

  • Committer: Bazaar Package Importer
  • Author(s): Mark Baker
  • Date: 2004-03-29 23:52:44 UTC
  • Revision ID: james.westby@ubuntu.com-20040329235244-fox1z1yv7d6vojoo
Tags: upstream-6.30
ImportĀ upstreamĀ versionĀ 6.30

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<HTML><HEAD><TITLE>Section 10: Places, scenery, directions and the map</TITLE></HEAD>
 
2
<BODY BGCOLOR="#FFFFFF">
 
3
<TABLE><P>
 
4
<TR><TD Valign="top"><A HREF="contents.html">Contents</A><BR><A HREF="chapter4.html">Back</A><BR><A HREF="section11.html">Forward</A><TD bgcolor="#F5DEB3"><BLOCKQUOTE><H3>10. Places, scenery, directions and the map</H3></BLOCKQUOTE><TR><TD><TD>
 
5
<P>
 
6
 
 
7
<BLOCKQUOTE>
 
8
It was a long cylinder of parchment, which he unrolled and spread out
 
9
on the floor, putting a stone on one end and holding the other.
 
10
I saw a drawing on it, but it made no sense.
 
11
<P>...John Christopher (<B>1922</B>--), <I>The White Mountains</I></BLOCKQUOTE>
 
12
<P>
 
13
 
 
14
 
 
15
Back to 'Ruins': what lies at the foot of the stone steps?  We'll now
 
16
add four rooms, connected together:
 
17
<PRE>
 
18
  Square Chamber  <-->  Web
 
19
       |       
 
20
    Corridor
 
21
       |       
 
22
     Shrine
 
23
</PRE>
 
24
with the Square Chamber lying underneath the original Forest location.
 
25
For instance, here's the Square Chamber's definition:
 
26
<PRE>
 
27
Object Square_Chamber "Square Chamber"
 
28
  with name "lintelled" "lintel" "lintels" "east" "south" "doorways",
 
29
       description
 
30
          "A sunken, gloomy stone chamber, ten yards across.  A shaft
 
31
           of sunlight cuts in from the steps above, giving the chamber
 
32
           a diffuse light, but in the shadows low lintelled doorways to
 
33
           east and south lead into the deeper darkness of the Temple.",
 
34
       u_to Forest, e_to Web, s_to Corridor,
 
35
  has  light;
 
36
</PRE>
 
37
 
 
38
Like the Forest, this place has <TT>light</TT>, however dim.  (If it didn't, the
 
39
player would never see it, since it would be dark, and the player hasn't yet
 
40
been given a lamp or torch of some kind.)  Now although this is a room,
 
41
and can't be referred to by the player in the way that a manipulable object
 
42
can, it still can have a <TT>name</TT> property.  These <TT>name</TT> words are those which
 
43
Inform knows "you don't need to refer to'', and it's a convention of the
 
44
genre that the designer should signpost off the game in this way.  (Note
 
45
that they'll only be looked at if what the player types is unrecognised,
 
46
so the word "east'' is understood quite normally; but a reference to
 
47
"east lintel'' will get the "don't need to refer to'' treatment.)
 
48
This room is unfurnished, so:
 
49
<PRE>
 
50
Object -&#62; "carved inscriptions"
 
51
  with name "carved" "inscriptions" "carvings" "marks" "markings" "symbols"
 
52
            "moving" "scuttling" "crowd" "of",
 
53
       initial
 
54
          "Carved inscriptions crowd the walls, floor and ceiling.",
 
55
       description "Each time you look at the carvings closely, they seem
 
56
           to be still.  But you have the uneasy feeling when you look
 
57
           away that they're scuttling, moving about.  Their meaning
 
58
           is lost on you.",
 
59
  has  static;
 
60
</PRE>
 
61
 
 
62
This is part of the fittings, hence the <TT>static</TT> attribute, which means it
 
63
can't be taken or moved.  As we went out of our way to describe a shaft
 
64
of sunlight, we'll include that as well:
 
65
<PRE>
 
66
Object -&#62; sunlight "shaft of sunlight"
 
67
  with name "shaft" "of" "sunlight" "sun" "light" "beam" "sunbeam" "ray"
 
68
            "rays" "sun^s",
 
69
       description "The shaft of sunlight glimmers motes of dust in the
 
70
           air, making it seem almost solid."
 
71
  has  scenery;
 
72
</PRE>
 
73
 
 
74
(The <TT></TT> symbol in <TT>"sun^s"</TT> means an apostrophe, so the word is "sun's''.)
 
75
Being <TT>scenery</TT> makes the object not only static but also not described
 
76
by the game unless actually examined by the player.  A true perfectionist
 
77
might add a <TT>before</TT> rule:
 
78
<PRE>
 
79
       before
 
80
       [;  Examine, Search: ;
 
81
           default: "It's only an insubstantial shaft of sunlight.";
 
82
       ],
 
83
</PRE>
 
84
 
 
85
so that the player can look at or through the sunlight, but any other
 
86
request involving them will be turned down.  Note that a <TT>default</TT>
 
87
rule, if given, means "any action except those already mentioned''.
 
88
<P>
 
89
 
 
90
We can't actually get into the Square Chamber yet, though.  Just because
 
91
there is a map connection up from here to the Forest, it doesn't follow
 
92
that there's a corresponding connection down.  So we must add a <TT>d_to</TT>
 
93
to the Forest, and while we're at it:
 
94
<PRE>
 
95
       d_to Square_Chamber,
 
96
       u_to "The trees are spiny and you'd cut your hands to ribbons
 
97
             trying to climb them.",
 
98
       cant_go "The rainforest-jungle is dense, and you haven't hacked
 
99
           through it for days to abandon your discovery now.  Really,
 
100
           you need a good few artifacts to take back to civilization
 
101
           before you can justify giving up the expedition.",
 
102
</PRE>
 
103
 
 
104
The property <TT>cant_go</TT> contains what is printed when the player tries to go
 
105
in a nonexistent direction, and replaces "You can't go that way''.
 
106
As is often the case with properties, instead of giving an actual
 
107
message you can instead give a routine to print one out, to vary what's
 
108
printed with the circumstances.  The Forest needs a <TT>cant_go</TT> because
 
109
in real life one could go in every direction from there: what we're
 
110
doing is explaining the game rules to the player: go underground, find some
 
111
ancient treasure, then get out to win.  The Forest's <TT>u_to</TT> property is
 
112
a string, not a room; this means that attempts to go up result only in
 
113
that string being printed.
 
114
<P>
 
115
 
 
116
Rooms also have rules of their own.  We might add the following <TT>before</TT>
 
117
rule to the Square Chamber:
 
118
<PRE>
 
119
       before
 
120
       [;  Insert:
 
121
               if (noun==mushroom &#38;&#38; second==sunlight)
 
122
               {   remove mushroom;
 
123
                  "You drop the mushroom on the floor, in the glare of
 
124
                   the shaft of sunlight.  It bubbles obscenely,
 
125
                   distends and then bursts into a hundred tiny insects
 
126
                   which run for the darkness in every direction.  Only
 
127
                   tiny crumbs of fungus remain.";
 
128
               }
 
129
       ],
 
130
</PRE>
 
131
 
 
132
The variables <TT>noun</TT> and <TT>second</TT> hold the first and second nouns
 
133
supplied with an action.  Rooms have <TT>before</TT> and <TT>after</TT> routines just as
 
134
objects do, and they apply to anything which happens in the given room. 
 
135
This particular rule could easily enough have been part of the definition of
 
136
the mushroom or the sunlight, and in general a room's rules are best used
 
137
only for geographical fixtures.
 
138
<P>
 
139
 
 
140
<P><TR><TD Valign="top"><IMG SRC="icons/ddbend.gif" ALT="/\/\"><TD bgcolor="#EEEEEE"><SMALL> Sometimes the room may be a different one after the action has
 
141
taken place.  The <TT>Go</TT> action, for instance, is offered to the <TT>before</TT>
 
142
routine of the room which is being left, and the <TT>after</TT> routine of the
 
143
room being arrived in.  For example:
 
144
<PRE>
 
145
       after
 
146
       [; Go: if (noun==d_obj)
 
147
              print "You feel on the verge of a great discovery...^";
 
148
       ],
 
149
</PRE>
 
150
 
 
151
will print the message when its room is entered via the "down" direction.
 
152
Note that since the message is printed with the <TT>print</TT> command,
 
153
there is no "return true'' from this routine, so it returns false:
 
154
and so the usual game rules resume after the printing of the message.
 
155
</SMALL>
 
156
<TR><TD><TD><P>
 
157
 
 
158
 
 
159
Some objects are present in many rooms at once.  The 'Ruins', for
 
160
instance, are misty:
 
161
<PRE>
 
162
Object low_mist "low mist"
 
163
  with name "low" "swirling" "mist",
 
164
       initial "A low mist swirls about your feet.",
 
165
       description "The mist carries a rich aroma of broth.",
 
166
       found_in  Square_Chamber  Forest,
 
167
       before
 
168
       [; Examine, Search: ;
 
169
          Smell:   &#60;&#60;Examine self&#62;&#62;;
 
170
          default: "The mist is too insubstantial.";
 
171
       ],
 
172
  has  static;
 
173
</PRE>
 
174
 
 
175
The <TT>found_in</TT> property gives a list of places in which the mist
 
176
is found (so far just the Square Room and the Forest).
 
177
<P>
 
178
 
 
179
<P><TR><TD Valign="top"><IMG SRC="icons/dbend.gif" ALT="/\"><TD bgcolor="#EEEEEE"><SMALL> If the rainforest contained many misty rooms, it would be tedious to
 
180
give the full list and even worse to have to alter it as the mist drifted
 
181
about in the course of the game.  Fortunately <TT>found_in</TT> can contain a
 
182
routine instead of a list.  This can look at the current <TT>location</TT> and say
 
183
whether or not the object should be put in it when the room is entered, e.g.,
 
184
<PRE>
 
185
Object Sun "Sun",
 
186
  with ...
 
187
       found_in
 
188
       [; if (location has light) rtrue;
 
189
       ],
 
190
  has  scenery;
 
191
</PRE>
 
192
 
 
193
</SMALL>
 
194
<TR><TD><TD><P>
 
195
 
 
196
<P><TR><TD Valign="top"><IMG SRC="icons/ddbend.gif" ALT="/\/\"><TD bgcolor="#EEEEEE"><SMALL> <TT>found_in</TT> is only consulted when the player's location changes,
 
197
so if the mist has to dramatically lift or move then it needs to be moved
 
198
or removed 'by hand'.  A good way to lift the mist forever is to <TT>remove</TT>
 
199
it, and then give it the <TT>absent</TT> attribute, which prevents it from
 
200
manifesting itself whatever <TT>found_in</TT> says.
 
201
</SMALL>
 
202
<TR><TD><TD><P>
 
203
 
 
204
<P>
 
205
Some pieces of scenery afflict the other four senses.  The mist smells
 
206
of broth, which means that if the player types "smell'' in a place
 
207
where the mist is, then she should be told about the broth.  For this,
 
208
a <TT>react_before</TT> rule attached to the mist is ideal:
 
209
<PRE>
 
210
       react_before
 
211
       [;  Smell: if (noun==0) &#60;&#60;Smell low_mist&#62;&#62;;
 
212
       ],
 
213
</PRE>
 
214
 
 
215
 
 
216
This is called a "react'' rule because the mist is reacting to the
 
217
fact that a <TT>Smell</TT> action is taking place nearby.  <TT>noun</TT> is compared
 
218
with zero to see if the player has indeed just typed "smell'' (not,
 
219
say, "smell crocus'').  Thus, when the action <TT>Smell</TT> takes place
 
220
near the mist, it is converted into <TT>Smell low_mist</TT>; whereas the
 
221
action <TT>Smell crocus</TT> would be left alone.
 
222
 
 
223
<P>
 
224
 
 
225
The five senses all have actions in Inform: <TT>Look</TT>, <TT>Listen</TT>,
 
226
<TT>Smell</TT>, <TT>Taste</TT> and <TT>Touch</TT>.  Of these, <TT>Look</TT> never has a noun
 
227
attached (because <TT>Examine</TT> is provided for close-ups), <TT>Smell</TT> and
 
228
<TT>Listen</TT> may or may not have while <TT>Taste</TT> and <TT>Touch</TT> always
 
229
have.
 
230
<P>
 
231
 
 
232
<P><TR><TD Valign="top"><IMG SRC="icons/exercise.gif" ALT="??"><TD bgcolor="#FBB9AC"><A NAME="ex5"><B>EXERCISE 5:</B><BR>(link to <A HREF="answers1/answer5.html">the answer</A>)<TR><TD><TD>  (Cf. 'Spellbreaker'.)  Make an orange cloud descend on the
 
233
player, which can't be seen through or walked out
 
234
of.
 
235
<P>
 
236
 
 
237
<P>
 
238
 
 
239
Directions (such as "north") are objects called <TT>n_obj</TT>, <TT>s_obj</TT>
 
240
and so on: in this case, <TT>in_obj</TT>.  (They are not to be confused with the
 
241
property names <TT>n_to</TT> and so on.)  Moreover, you can change these
 
242
directions: as far as Inform is concerned, a direction is any object in
 
243
the special object <TT>compass</TT>.
 
244
 
 
245
<P>
 
246
 
 
247
<P><TR><TD Valign="top"><IMG SRC="icons/dexercise.gif" ALT="??/\"><TD bgcolor="#FBB9AC"><A NAME="ex6"><B>EXERCISE 6:</B><BR>(link to <A HREF="answers1/answer6.html">the answer</A>)<TR><TD><TD> In the first millenium A.D., the Mayan peoples of the
 
248
Yucat\'an Peninsula had 'world colours' white (<I> sac</I>), red (<I> chac</I>),
 
249
yellow (<I> kan</I>) and black (<I> chikin</I>) for what we call the compass
 
250
bearings north, east, south, west (for instance west is associated
 
251
with 'sunset', hence black, the colour of night). Implement this.
 
252
<P>
 
253
 
 
254
<P><TR><TD Valign="top"><IMG SRC="icons/dexercise.gif" ALT="??/\"><TD bgcolor="#FBB9AC"><A NAME="ex7"><B>EXERCISE 7:</B><BR>(link to <A HREF="answers1/answer7.html">the answer</A>)<TR><TD><TD> (Cf. 'Trinity'.)  How can the entire game map
 
255
be suddenly east-west reflected?
 
256
 
 
257
<P>
 
258
 
 
259
<P><TR><TD Valign="top"><IMG SRC="icons/ddexercise.gif" ALT="??/\/\"><TD bgcolor="#FBB9AC"><A NAME="ex8"><B>EXERCISE 8:</B><BR>(link to <A HREF="answers1/answer8.html">the answer</A>)<TR><TD><TD>  Even when the map is reflected, there may be many
 
260
room descriptions referring to "east'' and "west'' by name.  Reflect
 
261
these too.
 
262
<P>
 
263
 
 
264
<P><TR><TD Valign="top"><IMG SRC="icons/dbend.gif" ALT="/\"><TD bgcolor="#EEEEEE"><SMALL> The ordinary Inform directions all have the <TT>number</TT>
 
265
property defined (initially set to zero): this is to provide a
 
266
set of scratch variables useful, for instance, when coding mazes.
 
267
</SMALL>
 
268
<TR><TD><TD><P>
 
269
 
 
270
<P><TR><TD Valign="top"><IMG SRC="icons/ddbend.gif" ALT="/\/\"><TD bgcolor="#EEEEEE"><SMALL> If the constant <TT>WITHOUT_DIRECTIONS</TT> is defined before
 
271
inclusion of the library files, then 10 of the default direction
 
272
objects are not defined by the library.  The designer is expected to
 
273
define alternative ones (and put them in the <TT>compass</TT> object);
 
274
otherwise the game will be rather static.  (The "in" and "out"
 
275
directions are still created, because they're needed for getting
 
276
into and out of enterable
 
277
objects.)
 
278
 
 
279
</SMALL>
 
280
<TR><TD><TD><P>
 
281
 
 
282
<P><TR><TD Valign="top"><IMG SRC="icons/refs.gif" ALT="*"><TD bgcolor="#EEEEEE"><B>REFERENCES:</B><BR><SMALL>  'Advent' has a very tangled-up map in places (see the
 
283
mazes) and a well-constructed exterior of forest and valley
 
284
giving an impression of space with remarkably few rooms.  The
 
285
mist object uses <TT>found_in</TT> to the full, and see also the
 
286
stream (a single object representing every watercourse in the game).
 
287
Bedquilt and the Swiss Cheese room offer classic confused-exit
 
288
puzzles.
 
289
<BR>
 
290
For a simple movement rule using <TT>e_to</TT>, see the Office in
 
291
'Toyshop'.
 
292
<BR>
 
293
The library extension "smartcantgo.h'' by David Wagner
 
294
provides a system for automatically printing out "You can only go
 
295
east and north.''-style messages.
 
296
<BR> 'A Scenic View', by Richard Barnett, demonstrates
 
297
a system for providing examinable scenery much more concisely
 
298
(without defining so many objects).
 
299
</SMALL>
 
300
<TR><TD><TD><P>
 
301
 
 
302
 
 
303
</TABLE>
 
304
<HR><A HREF="contents.html">Contents</A> / <A HREF="chapter4.html">Back</A> / <A HREF="section11.html">Forward</A> <BR>
 
305
<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 &#169; Graham Nelson 1993, 1994, 1995, 1996, 1997: all rights reserved.</I></SMALL></BODY></HTML>