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

« back to all changes in this revision

Viewing changes to inform-6.31.1/manual/s16.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;16: Reading matter and consultation</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="s15.html" title="&#167;15: Things to enter, travel in and push around">prev</a> /
 
14
 <a href="s17.html" title="&#167;17: People and animals">next</a> /
 
15
 <a href="dm4index.html">index</a>
 
16
</p>
 
17
<div class="page">
 
18
<a id="p141" name="p141"></a>
 
19
<h2>&#167;16 &nbsp; Reading matter and consultation</h2>
 
20
 
 
21
<blockquote>Making books is a skilled trade, like making clocks.<br>
 
22
&#8212; Jean de la Bruy&egrave;re (1645&#8211;1696)</blockquote>
 
23
 
 
24
<p class="normal"><span class="atleft"><img src="dm4-141_1.jpg" alt=""></span>
 
25
&#8220;Look up figure 18 in the engineering textbook&#8221; is a 
 
26
difficult line for Inform to understand, because almost anything could 
 
27
appear in the first part: even its format depends on what the second 
 
28
part is. This kind of request, and more generally</p>
 
29
 
 
30
<p class="syntax">&gt;<tt>look up</tt> &#8249;<span class="token">any words here</span>&#8250; <tt>in</tt> &#8249;<span class="token">the object</span>&#8250;<br>
 
31
&gt;<tt>read about</tt> &#8249;<span class="token">any words here</span>&#8250; <tt>in</tt> &#8249;<span class="token">the object</span>&#8250;<br>
 
32
&gt;<tt>consult</tt> &#8249;<span class="token">the object</span>&#8250; <tt>about</tt> &#8249;<span class="token">any words here</span>&#8250;</p>
 
33
 
 
34
<p class="normal">cause the <code>Consult</code> action. In such cases, 
 
35
the <code>noun</code> is the book and there is no <code>second</code> 
 
36
object. Instead, the object has to parse the &#8249;<span class="token">any words here</span>&#8250; part 
 
37
itself. The following variables are set up to make this possible:</p>
 
38
 
 
39
<p class="syntax"><code>consult_from</code> holds the number of 
 
40
the first word in the &#8249;<span class="token">any&#8230</span>&#8250; clause;<br>
 
41
<code>consult_words</code> holds the number of words in the 
 
42
&#8249;<span class="token">any&#8230;</span>&#8250; clause.</p>
 
43
 
 
44
<p class="normal">The &#8249;<span class="token">any words here</span>&#8250; 
 
45
clause must contain at least one word. The words given can be parsed 
 
46
using library routines like <code>NextWord()</code>, 
 
47
<code>TryNumber(word-number)</code> and so on: see 
 
48
<a href="s28.html">&#167;28</a> for full details. As usual, the 
 
49
<code>before</code> routine should return <code>true</code> if it 
 
50
has managed to deal with the action; returning <code>false</code>
 
51
will make the library print &#8220;You discover nothing of interest 
 
52
in&#8230;&#8221;.</p>
 
53
 
 
54
<p class="indent">Little hints are placed here and there in the 
 
55
&#8216;Ruins&#8217;, written in the glyphs of a not altogether 
 
56
authentic dialect of Mayan. Our explorer has, naturally, come 
 
57
equipped with the latest and finest scholarship on the subject:</p>
 
58
 
 
59
<p class="lynxonly"></p>
 
60
<pre class="code">
 
61
Object dictionary &quot;Waldeck's Mayan dictionary&quot;
 
62
  with name 'dictionary' 'local' 'guide' 'book' 'mayan'
 
63
            'waldeck' 'waldeck^s',
 
64
       description &quot;Compiled from the unreliable lithographs of the
 
65
           legendary raconteur and explorer ~Count~ Jean Frederic
 
66
           Maximilien Waldeck (1766??-1875), this guide contains
 
67
           what little is known of the glyphs used in the local
 
68
           ancient dialect.&quot;,
 
69
       correct false,
 
70
       before [ w1 w2 glyph;
 
71
         Consult:<a id="p142" name="p142"></a>
 
72
             wn = consult_from;
 
73
             w1 = NextWord(); ! First word of subject
 
74
             w2 = NextWord(); ! Second word (if any) of subject
 
75
             if (consult_words==1 &amp;&amp; w1~='glyph' or 'glyphs') glyph = w1;
 
76
             else if (consult_words==2 &amp;&amp; w1=='glyph') glyph = w2;
 
77
             else if (consult_words==2 &amp;&amp; w2=='glyph') glyph = w1;
 
78
             else &quot;Try ~look up &lt;name of glyph&gt; in book~.&quot;;
 
79
             switch (glyph) {
 
80
                 'q1': &quot;(This is one glyph you have memorised!)^^
 
81
                     Q1: ~sacred site~.&quot;;
 
82
                 'crescent': &quot;Crescent: believed pronounced ~xibalba~,
 
83
                     though its meaning is unknown.&quot;;
 
84
                 'arrow': &quot;Arrow: ~journey; becoming~.&quot;;
 
85
                 'skull': &quot;Skull: ~death, doom; fate (not nec. bad)~.&quot;;
 
86
                 'circle': &quot;Circle: ~the Sun; also life, lifetime~.&quot;;
 
87
                 'jaguar': &quot;Jaguar: ~lord~.&quot;;
 
88
                 'monkey': &quot;Monkey: ~priest?~.&quot;;
 
89
                 'bird': if (self.correct) &quot;Bird: ~dead as a stone~.&quot;;
 
90
                     &quot;Bird: ~rich, affluent?~.&quot;;
 
91
                 default: &quot;That glyph is so far unrecorded.&quot;;
 
92
             }
 
93
       ],
 
94
  has  proper;
 
95
</pre>
 
96
 
 
97
<p class="normal">Note that this understands any of the forms &#8220;q1&#8221;, 
 
98
&#8220;glyph q1&#8221; or &#8220;q1 glyph&#8221;. (These aren't genuine 
 
99
Maya glyphs, but some of the real ones once had similar names, dating 
 
100
from when their syllabic equivalents weren't known.)</p>
 
101
 
 
102
<a id="ex25" name="ex25"></a>
 
103
<p class="aside"><span class="warning"><b>&#8226;</b>&#9650;&#9650;
 
104
<b><a href="sa6.html#ans25">EXERCISE 25</a></b></span><br>
 
105
To mark the 505th anniversary of William Tyndale, the first English 
 
106
translator of the New Testament (who was born some time around 
 
107
1495 and burned as a heretic in Vilvorde, Denmark, in 1535), prepare 
 
108
an Inform edition.</p>
 
109
 
 
110
<p class="dotbreak">� � � � �</p>
 
111
 
 
112
<p class="aside"><span class="warning">&#9650;&#9650;</span>
 
113
Ordinarily, a request by the player to &#8220;read&#8221; something 
 
114
is translated into an <code>Examine</code> action. But the &#8220;read&#8221; 
 
115
verb is defined independently of the &#8220;examine&#8221; verb
 
116
in order to make it easy to separate the two requests. For instance:</p>
 
117
 
 
118
<p class="lynxonly"></p>
 
119
<pre class="code">
 
120
Attribute legible;
 
121
...
 
122
Object textbook &quot;textbook&quot;
 
123
  with name 'engineering' 'textbook' 'text' 'book',
 
124
       description &quot;What beautiful covers and spine!&quot;,<a id="p143" name="p143"></a>
 
125
       before [;
 
126
           Consult, Read:
 
127
               &quot;The pages are full of senseless equations.&quot;;
 
128
       ],
 
129
  has  legible;
 
130
...
 
131
[ ReadSub;
 
132
  &lt;&lt;Examine noun&gt;&gt;; 
 
133
];
 
134
Extend 'read' first * legible -&gt; Read;
 
135
</pre>
 
136
 
 
137
<p class="aside">Note that &#8220;read&#8221; causes a <code>Read</code> 
 
138
action only for <code>legible</code> objects, and otherwise causes
 
139
<code>Examine</code> in the usual way. <code>ReadSub</code> is coded 
 
140
as a translation to <code>Examine</code> as well, so that
 
141
if a <code>legible</code> object doesn't provide a <code>Read</code> 
 
142
rule then an <code>Examine</code> happens after all.</p>
 
143
 
 
144
<p class="aside"><span class="warning"><b>&#8226;</b>
 
145
<b>REFERENCES</b></span><br>
 
146
Another possibility for parsing commands like &#8220;look up &#8249;<span class="token">something</span>&#8250; 
 
147
in the catalogue&#8221;, where any object name might appear as the 
 
148
&#8249;<span class="token">something</span>&#8250;, would be to extend the grammar 
 
149
for &#8220;look&#8221;. See <a href="s30.html">&#167;30</a>.</p>
 
150
 
 
151
</div>
 
152
<p class="navbar">
 
153
 <a href="index.html">home</a> /
 
154
 <a href="contents.html">contents</a> /
 
155
 <a href="ch3.html" title="Chapter III: The Model World">chapter III</a> /
 
156
 <a href="s15.html" title="&#167;15: Things to enter, travel in and push around">prev</a> /
 
157
 <a href="s17.html" title="&#167;17: People and animals">next</a> /
 
158
 <a href="dm4index.html">index</a>
 
159
</p>
 
160
</body>
 
161
</html>
 
162