~ubuntu-branches/ubuntu/vivid/inform/vivid

« back to all changes in this revision

Viewing changes to inform-6.31.1/manual/s8.html

  • Committer: Bazaar Package Importer
  • Author(s): Jan Christoph Nordholz
  • Date: 2008-05-26 22:09:44 UTC
  • mfrom: (2.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080526220944-ba7phz0d1k4vo7wx
Tags: 6.31.1+dfsg-1
* Remove a considerable number of files from the package
  due to unacceptable licensing terms.
* Repair library symlinks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 
2
<html>
 
3
<head>
 
4
<title>DM4 &#167;8: Places and scenery</title>
 
5
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
 
6
<link rel="stylesheet" type="text/css" href="dm4.css">
 
7
</head>
 
8
<body>
 
9
<p class="navbar">
 
10
 <a href="index.html">home</a> /
 
11
 <a href="contents.html">contents</a> /
 
12
 <a href="ch3.html" title="Chapter III: The Model World">chapter III</a> /
 
13
 <a href="ch3.html" title="Chapter III: The Model World">prev</a> /
 
14
 <a href="s9.html" title="&#167;9: Directions and the map">next</a> /
 
15
 <a href="dm4index.html">index</a>
 
16
</p>
 
17
<div class="page">
 
18
<a id="p116" name="p116"></a>
 
19
<h2>&#167;8 &nbsp; Places and scenery</h2>
 
20
 
 
21
<p class="normal"><span class="atleft"><img src="dm4-116_1.jpg" alt=""></span>
 
22
In this longer chapter the model world of an Inform game will be
 
23
explored and examples will gradually complete the &#8216;Ruins&#8217; 
 
24
begun in Chapter II. So far, &#8216;Ruins&#8217; contains just a 
 
25
location of rainforest together with some rules about photography. 
 
26
The immediate need is for a more substantial map, beginning with a 
 
27
sunken chamber. Like the Forest, this too has <code>light</code>, however dim. If 
 
28
it didn't, the player would never see it: in Inform's world darkness 
 
29
prevails unless the designer provides some kind of lamp or, as in this 
 
30
case, ambient light.</p>
 
31
 
 
32
<p class="lynxonly"></p>
 
33
<pre class="code">
 
34
Object Square_Chamber &quot;Square Chamber&quot;
 
35
  with name 'lintelled' 'lintel' 'lintels' 'east' 'south' 'doorways',
 
36
       description
 
37
           &quot;A sunken, gloomy stone chamber, ten yards across. A shaft
 
38
           of sunlight cuts in from the steps above, giving the
 
39
           chamber a diffuse light, but in the shadows low lintelled
 
40
           doorways to east and south lead into the deeper darkness
 
41
           of the Temple.&quot;,
 
42
  has  light;
 
43
</pre>
 
44
 
 
45
<p class="normal">This room has a <code>name</code> property even 
 
46
though rooms are not usually referred to by players. The nouns given 
 
47
are words which Inform knows &#8220;you don't need to refer to&#8221;, 
 
48
and it's a convention of the genre that the designer should signpost 
 
49
the game in this way. For the game to talk about something and later
 
50
deny all knowledge &#8211; &#8220;I can't see any such thing&#8221; 
 
51
&#8211; is not merely rude but harmful to the player's illusion of 
 
52
holding a conversation about a real world. Better to parry with:</p>
 
53
 
 
54
<p class="output">&gt;<tt>examine lintel</tt><br><a id="p117" name="p117"></a>
 
55
That's not something you need to refer to in the course of this game.</p>
 
56
 
 
57
<p class="dotbreak">� � � � �</p>
 
58
 
 
59
<p class="normal">Not all of the Square Chamber's d&eacute;cor is so 
 
60
irrelevant:</p>
 
61
 
 
62
<p class="lynxonly"></p>
 
63
<pre class="code">
 
64
Object -&gt; &quot;carved inscriptions&quot;
 
65
  with name 'carved' 'inscriptions' 'carvings' 'marks' 'markings'
 
66
           'symbols' 'moving' 'scuttling' 'crowd' 'of',
 
67
       initial
 
68
           &quot;Carved inscriptions crowd the walls, floor and ceiling.&quot;,
 
69
       description
 
70
           &quot;Each time you look at the carvings closely, they seem
 
71
           to be still. But you have the uneasy feeling when you
 
72
           look away that they're scuttling, moving about. Two
 
73
           glyphs are prominent: Arrow and Circle.&quot;,
 
74
  has  static pluralname;
 
75
</pre>
 
76
 
 
77
<p class="normal">The <code>static</code> attribute means that the inscriptions 
 
78
can't be taken or moved. As we went out of our way to describe a shaft 
 
79
of sunlight, we'll include that as well:</p>
 
80
 
 
81
<p class="lynxonly"></p>
 
82
<pre class="code">
 
83
Object -&gt; sunlight &quot;shaft of sunlight&quot;
 
84
  with name 'shaft' 'of' 'sunlight' 'sun' 'light' 'beam' 'sunbeam'
 
85
           'ray' 'rays' 'sun^s' 'sunlit' 'air' 'motes' 'dust',
 
86
       description
 
87
           &quot;Motes of dust glimmer in the shaft of sunlit air, so
 
88
           that it seems almost solid.&quot;,
 
89
  has  scenery;
 
90
</pre>
 
91
 
 
92
<p class="normal">The <code>^</code> symbol in <code>&quot;sun^s&quot;</code> 
 
93
means an apostrophe, so the word is &#8220;sun's&#8221;. This
 
94
object has been given the constant name <code>sunlight</code> because 
 
95
other parts of the &#8216;Ruins&#8217; source code will need to refer 
 
96
to it later on. Being <code>scenery</code> means that the object is 
 
97
not only static but also not described by the game unless actually
 
98
examined by the player. A perfectionist might add a <code>before</code> 
 
99
rule:</p>
 
100
 
 
101
<p class="lynxonly"></p>
 
102
<pre class="code">
 
103
before [;
 
104
    Examine, Search: ;
 
105
    default: &quot;It's only an insubstantial shaft of sunlight.&quot;;
 
106
],
 
107
</pre>
 
108
 
 
109
<p class="normal">so that the player can look at or through the sunlight, 
 
110
but any other request involving them will be turned down. Note that 
 
111
a <code>default</code> rule, if given, means &#8220;any action except 
 
112
those already mentioned&#8221;.</p>
 
113
 
 
114
<a id="p118" name="p118"></a>
 
115
<p class="aside"><span class="warning">&#9650;</span>
 
116
Objects having <code>scenery</code> are assumed to be mentioned in 
 
117
the description text of the room, just as the &#8220;shaft of sunlight&#8221; 
 
118
is mentioned in that of the Square Chamber. Giving an object <code>concealed</code> 
 
119
marks it as something which is present to a player who knows about it, 
 
120
but hidden from the casual eye. It will not be cited in lists of objects
 
121
present in the room, and &#8220;take all&#8221; will not take it, but 
 
122
&#8220;take secret dossier&#8221;, or whatever, will work. (Designers 
 
123
seldom need <code>concealed</code>, but the library uses it all the
 
124
time, because the player-object is concealed.)</p>
 
125
 
 
126
<p class="dotbreak">� � � � �</p>
 
127
 
 
128
<p class="normal">Some scenery must spread across several rooms. The 
 
129
&#8216;Ruins&#8217;, for instance, are misty, and although we <em>could</em> 
 
130
design them with a different &#8220;mist&#8221; object in every misty 
 
131
location, this would become tiresome. In &#8216;Advent&#8217;, 
 
132
for instance, a stream runs through seven locations, while mist which 
 
133
(we are told) is &#8220;frequently a sign of a deep pit leading down 
 
134
to water&#8221; can be found in ten different caves. Here is a 
 
135
better solution:</p>
 
136
 
 
137
<p class="lynxonly"></p>
 
138
<pre class="code">
 
139
Object low_mist &quot;low mist&quot;
 
140
  with name 'low' 'swirling' 'mist',
 
141
       description &quot;The mist has an aroma reminiscent of tortilla.&quot;,
 
142
       found_in  Square_Chamber  Forest,
 
143
       before [;
 
144
           Examine, Search: ;
 
145
           Smell: &lt;&lt;Examine self&gt;&gt;;
 
146
           default: &quot;The mist is too insubstantial.&quot;;
 
147
       ],
 
148
  has  scenery;
 
149
</pre>
 
150
 
 
151
<p class="normal">The <code>found_in</code> property gives a list 
 
152
of places in which the mist is found: so far, just the Square Chamber 
 
153
and the Forest.</p>
 
154
 
 
155
<p class="aside"><span class="warning">&#9650;</span>
 
156
This allows for up to 32 misty locations. If scenery has to be visible 
 
157
even more widely than that, or if it has to change with circumstances 
 
158
(for instance, if the mist drifts) then it is simpler to give a routine 
 
159
instead of a list. This can look at the current location and say whether 
 
160
or not the object should be present, as in the following example from 
 
161
a game taking place at night:</p>
 
162
 
 
163
<p class="lynxonly"></p>
 
164
<pre class="code">
 
165
Object Procyon &quot;Procyon&quot;,
 
166
  with name 'procyon' 'alpha' 'canis' 'minoris' 'star',
 
167
       description &quot;A double-star eleven light years distant.&quot;,
 
168
       found_in [;
 
169
           return (location ofclass OutsideRoom);
 
170
       ],
 
171
  has  scenery;
 
172
</pre>
 
173
 
 
174
<a id="p119" name="p119"></a>
 
175
<p class="aside"><code>found_in</code> is only consulted when the player's 
 
176
location changes, and works by moving objects around to give the illusion 
 
177
that they are in several places at once: thus, if the player walks from 
 
178
a dark field to a hilltop, Procyon will be moved ahead to the hilltop
 
179
just in advance of the player's move. This illusion is good enough for 
 
180
most practical purposes, but sometimes needs a little extra work to maintain, 
 
181
for instance if the sky must suddenly cloud over, concealing the stars. 
 
182
Since it often happens that an object must be removed from all the 
 
183
places in which it would otherwise appear, an attribute called 
 
184
<code>absent</code> is provided which overrides <code>found_in</code> 
 
185
and declares that the object is found nowhere. Whatever change is made 
 
186
to <code>found_in</code>, or in giving or removing <code>absent</code>, 
 
187
the Inform library needs also to be notified that changes have taken 
 
188
place. For instance, if you need to occult Procyon behind the moon 
 
189
for a while, then:</p>
 
190
 
 
191
<p class="lynxonly"></p>
 
192
<pre class="code">give Procyon absent; MoveFloatingObjects();</pre>
 
193
 
 
194
<p class="aside">The library routine <code>MoveFloatingObjects</code> 
 
195
keeps the books straight after a change of state of <code>found_in</code> 
 
196
or <code>absent</code>.</p>
 
197
 
 
198
<p class="dotbreak">� � � � �</p>
 
199
 
 
200
<p class="normal">Whereas Procyon is entirely visual, some scenery 
 
201
items may afflict the other four senses. In &#8216;Ruins&#8217;, 
 
202
the <code>Forest</code> contains the rule:</p>
 
203
 
 
204
<p class="lynxonly"></p>
 
205
<pre class="code">
 
206
before [;
 
207
    Listen: &quot;Howler monkeys, bats, parrots, macaw.&quot;;
 
208
],
 
209
</pre>
 
210
 
 
211
<p class="normal">Besides which, we have already said that the mist 
 
212
smells of tortilla, which means that if the player types &#8220;smell&#8221; 
 
213
in a place where the mist is, there should clearly be some reaction. 
 
214
For this, a <code>react_before</code> rule attached to the mist is
 
215
ideal:</p>
 
216
 
 
217
<p class="lynxonly"></p>
 
218
<pre class="code">
 
219
react_before [;
 
220
    Smell: if (noun == nothing) &lt;&lt;Smell self&gt;&gt;;
 
221
],
 
222
</pre>
 
223
 
 
224
<p class="normal">This is called a &#8220;react&#8221; rule because 
 
225
the mist is reacting to the fact that a <code>Smell</code> action is 
 
226
taking place nearby. <code>noun</code> is compared with <code>nothing</code> 
 
227
to see if the player has indeed just typed &#8220;smell&#8221; and 
 
228
not, say, &#8220;smell crocus&#8221;. Thus, when the action 
 
229
<code>Smell</code> takes place near the mist, it is converted into 
 
230
<code>Smell low_mist</code>, whereas the action <code>Smell 
 
231
crocus</code> would be left alone.
 
232
 
 
233
<p class="indent">The five senses all have actions in Inform: 
 
234
<code>Look</code>, <code>Listen</code>, <code>Smell</code>, 
 
235
<code>Taste</code> and <code>Touch</code>. Of these, <code>Look</code> 
 
236
never has a noun attached (because <code>Examine</code>,
 
237
<code>LookUnder</code> and <code>Search</code> are provided for 
 
238
close-up views), <code>Smell</code> and <code>Listen</code> may or 
 
239
may not have while <code>Taste</code> and <code>Touch</code> always 
 
240
have.</p>
 
241
 
 
242
<a id="p120" name="p120"></a>
 
243
<a name="ex6"></a>
 
244
<p class="aside"><span class="warning"><b>&#8226;</b>
 
245
<b><a href="sa6.html#ans6">EXERCISE 6</a></b></span><br>
 
246
(Cf. &#8216;Spellbreaker&#8217;.) Make an orange cloud descend on 
 
247
the player, which can't be seen through or walked out of.</p>
 
248
 
 
249
<p class="dotbreak">� � � � �</p>
 
250
 
 
251
<p class="normal">Rooms also react to actions that might occur in them 
 
252
and have their own <code>before</code> and <code>after</code> rules. 
 
253
Here's one for the Square Chamber:</p>
 
254
 
 
255
<p class="lynxonly"></p>
 
256
<pre class="code">
 
257
before [;
 
258
    Insert:
 
259
        if (noun == eggsac &amp;&amp; second == sunlight) {
 
260
            remove eggsac; move stone_key to self;
 
261
            &quot;You drop the eggsac into the glare of the shaft of
 
262
            sunlight. It bubbles obscenely, distends and then
 
263
            bursts into a hundred tiny insects which run in all
 
264
            directions into the darkness. Only spatters of slime
 
265
            and a curious yellow-stone key remain on the chamber
 
266
            floor.&quot;;
 
267
        }
 
268
],
 
269
</pre>
 
270
 
 
271
<p class="normal">(The variables <code>noun</code> and <code>second</code> 
 
272
hold the first and second nouns supplied with an action.) As it happens 
 
273
this rule could as easily have been part of the definition of the eggsac 
 
274
or the sunlight, but <code>before</code> and <code>after</code> rules 
 
275
for rooms are invaluable to code up geographical oddities.</p>
 
276
 
 
277
<a name="ex7"></a>
 
278
<p class="aside"><span class="warning"><b>&#8226;</b>
 
279
<b><a href="sa6.html#ans7">EXERCISE 7</a></b></span><br>
 
280
Create a room for &#8216;Ruins&#8217; called the Wormcast, which has 
 
281
the oddity that anything dropped there ends up back in the Square Chamber.</p>
 
282
 
 
283
<p class="aside"><span class="warning">&#9650;</span>
 
284
Sometimes the room may be a different one after the action has taken 
 
285
place. The <code>Go</code> action, for instance, is offered to the 
 
286
<code>before</code> routine of the room which is being left, and 
 
287
the <code>after</code> routine of the room being arrived in. For example:</p>
 
288
 
 
289
<p class="lynxonly"></p>
 
290
<pre class="code">
 
291
after [;
 
292
    Go: if (noun == w_obj)
 
293
        print &quot;You feel an overwhelming sense of relief.^&quot;;
 
294
],
 
295
</pre>
 
296
 
 
297
<p class="aside">will print the message when its room is entered from 
 
298
the &#8220;west&quot; direction. Note that this routine returns <code>false</code>, 
 
299
in the absence of any code telling it to do otherwise, which means 
 
300
that the usual game rules resume after the printing of the message.</p>
 
301
 
 
302
<a id="p121" name="p121"></a>
 
303
<p class="aside"><span class="warning"><b>&#8226;</b>
 
304
<b>REFERENCES</b></span><br>
 
305
&#8216;A Scenic View&#8217; by Richard Barnett demonstrates a system 
 
306
for providing examinable scenery much more concisely (without defining 
 
307
so many objects). &nbsp;
 
308
<span class="warning"><b>&#8226;</b></span><code>found_in</code> 
 
309
can allow a single object to represent many different but similar objects 
 
310
across a game, and a good example is found in Martin Braun's <tt>&quot;elevator.inf&quot;</tt> 
 
311
example game, where every floor of a building has an up-arrow and a 
 
312
down-arrow button to summon an elevator.</p>
 
313
 
 
314
</div>
 
315
<p class="navbar">
 
316
 <a href="index.html">home</a> /
 
317
 <a href="contents.html">contents</a> /
 
318
 <a href="ch3.html" title="Chapter III: The Model World">chapter III</a> /
 
319
 <a href="ch3.html" title="Chapter III: The Model World">prev</a> /
 
320
 <a href="s9.html" title="&#167;9: Directions and the map">next</a> /
 
321
 <a href="dm4index.html">index</a>
 
322
</p>
 
323
</body>
 
324
</html>
 
325
 
 
326