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

« back to all changes in this revision

Viewing changes to html/sectionA10.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
 
<HTML><HEAD><TITLE>Section A10: Entry points and meaningful constants</TITLE></HEAD>
2
 
<BODY BGCOLOR="#FFFFFF">
3
 
<TABLE><P>
4
 
<TR><TD Valign="top"><A HREF="contents.html">Contents</A><BR><A HREF="sectionA9.html">Back</A><BR><A HREF="sectionA11.html">Forward</A><TD bgcolor="#F5DEB3"><BLOCKQUOTE><H3>A10. Entry points and meaningful constants</H3></BLOCKQUOTE><TR><TD><TD>
5
 
Entry points are routines which you can provide, if you choose to, and which
6
 
are called by the library routines to give you the option of changing the
7
 
rules.  All games <I> must</I> define an <TT>Initialise</TT> routine, which is
8
 
obliged to set the <TT>location</TT> variable to a room; the rest are
9
 
optional.bigskip
10
 
<P>
11
 
 
12
 
<DT><B><TT>AfterLife</TT></B><DD>
13
 
 
14
 
When the player has died (a condition signalled by the variable <TT>deadflag</TT>
15
 
being set to a non-zero value other than 2, which indicates winning), this
16
 
routine is called: by setting <TT>deadflag=0</TT> again it can resurrect the
17
 
player.
18
 
<P>
19
 
 
20
 
<DT><B><TT>AfterPrompt</TT></B><DD>
21
 
 
22
 
Called just after the prompt is printed: therefore, called after all the
23
 
printing for this turn is definitely over.  A useful opportunity to
24
 
use <TT>box</TT> to display quotations without them scrolling away.
25
 
<P>
26
 
 
27
 
<DT><B><TT>Amusing</TT></B><DD>
28
 
 
29
 
Called to provide an 'afterword' for players who have won: for instance, it
30
 
might advertise some features which a successful player might never have
31
 
noticed.  (But only if you have defined the constant <TT>AMUSING_PROVIDED</TT> in
32
 
your own code.)
33
 
<P>
34
 
 
35
 
<DT><B><TT>BeforeParsing</TT></B><DD>
36
 
 
37
 
Called after the parser has read in some text and set up the
38
 
<TT>buffer</TT> and <TT>parse</TT> tables, but has done nothing else yet (except
39
 
to set the word marker <TT>wn</TT> to 1).  The routine can do anything it
40
 
likes to these tables, and can leave the word marker anywhere; there
41
 
is no meaningful return value.
42
 
<P>
43
 
 
44
 
<DT><B><TT>ChooseObjects(obj,c)</TT></B><DD>
45
 
 
46
 
When <TT>c</TT> is 0, the parser is processing an "all'' and has
47
 
decided to exclude <TT>obj</TT> from it; when <TT>c</TT> is 1, it has
48
 
decided to include it.  Returning 1 forces inclusion,
49
 
returning 2 forces exclusion and returning 0 lets the parser's
50
 
decision stand.  When <TT>c</TT> is 2, the parser wants help in
51
 
resolving an ambiguity: using the <TT>action_to_be</TT> variable
52
 
the routine must decide how appropriate <TT>obj</TT> is for the
53
 
given action and return a score of 0 to 9 accordingly.  See <A HREF="section29.html">Section 29</A>.
54
 
<P>
55
 
 
56
 
<DT><B><TT>DarkToDark</TT></B><DD>
57
 
 
58
 
Called when a player goes from one dark room into another one; a splendid
59
 
excuse to kill the player off.
60
 
<P>
61
 
 
62
 
<DT><B><TT>DeathMessage</TT></B><DD>
63
 
 
64
 
Prints up "You have died" style messages, for <TT>deadflag</TT> values of 3 or
65
 
more.  (If you choose ever to set <TT>deadflag</TT> to such.)
66
 
<P>
67
 
 
68
 
<DT><B><TT>GamePostRoutine</TT></B><DD>
69
 
 
70
 
A kind of super-<TT>after</TT> rule, which applies to all actions in the game,
71
 
whatever they are: use only in the last resort.
72
 
<P>
73
 
 
74
 
<DT><B><TT>GamePreRoutine</TT></B><DD>
75
 
 
76
 
A kind of super-<TT>before</TT> rule, which applies to all actions in the game,
77
 
whatever they are: use only in the last resort.
78
 
<P>
79
 
 
80
 
<DT><B><TT>Initialise</TT></B><DD>
81
 
 
82
 
A compulsory routine, which must set <TT>location</TT> and is convenient for
83
 
miscellaneous initialising, perhaps for random settings.
84
 
<P>
85
 
 
86
 
<DT><B><TT>InScope</TT></B><DD>
87
 
 
88
 
An opportunity to place extra items in scope during parsing, or to change
89
 
the scope altogether.  If <TT>et_flag</TT> is 1 when this is called, the scope is
90
 
being worked out for <TT>each_turn</TT> reasons; otherwise for everyday parsing.
91
 
<P>
92
 
 
93
 
<DT><B><TT>LookRoutine</TT></B><DD>
94
 
 
95
 
Called at the end of every <TT>Look</TT> description.
96
 
<P>
97
 
 
98
 
<DT><B><TT>NewRoom</TT></B><DD>
99
 
 
100
 
Called when the room changes, before any description of it is printed.  This
101
 
happens in the course of ordinary movements or use of <TT>PlayerTo</TT>, but may
102
 
not happen if the game uses <TT>move</TT> to shift the player object directly.
103
 
<P>
104
 
 
105
 
<DT><B><TT>ParseNoun(obj)</TT></B><DD>
106
 
 
107
 
To do the job of parsing the <TT>name</TT> property (if <TT>parse_name</TT> hasn't done
108
 
it already).  This takes one argument, the object in question, and returns
109
 
a value as if it were a <TT>parse_name</TT> routine.
110
 
<P>
111
 
 
112
 
<DT><B><TT>ParseNumber(text,n)</TT></B><DD>
113
 
 
114
 
An opportunity to parse numbers in a different (or additional) way.  The
115
 
text to be parsed is a byte array of length <TT>n</TT> starting at <TT>text</TT>.
116
 
<P>
117
 
 
118
 
<DT><B><TT>ParserError(pe)</TT></B><DD>
119
 
 
120
 
The chance to print different parser error messages (like "I don't
121
 
understand that sentence'').  <TT>pe</TT> is the parser error number (see <A HREF="section29.html">Section 29</A>).
122
 
<P>
123
 
 
124
 
<DT><B><TT>PrintRank</TT></B><DD>
125
 
 
126
 
Completes the printing of the score.  You might want to change this, so as
127
 
to make the ranks something like "junior astronaut" or "master
128
 
catburglar" or whatever suits your game.
129
 
<P>
130
 
 
131
 
<DT><B><TT>PrintVerb(v)</TT></B><DD>
132
 
 
133
 
A chance to change the verb printed out in a parser question (like "What do
134
 
you want to (whatever)?'') in case an unusual verb via <TT>UnknownVerb</TT> has
135
 
been constructed.  <TT>v</TT> is the dictionary address of the verb.
136
 
Returns true (or 1) if it has printed something.
137
 
<P>
138
 
 
139
 
<DT><B><TT>PrintTaskName(n)</TT></B><DD>
140
 
 
141
 
Prints the name of task <TT>n</TT> (such as "driving the car").
142
 
<P>
143
 
 
144
 
<DT><B><TT>TimePasses</TT></B><DD>
145
 
 
146
 
Called after every turn (but not, for instance, after a command like
147
 
"score" or "save").  It's much more elegant to use timers and daemons, or
148
 
<TT>each_turn</TT> routines for individual rooms -- using this is a last resort.
149
 
<P>
150
 
 
151
 
<DT><B><TT>UnknownVerb</TT></B><DD>
152
 
 
153
 
Called by the parser when it hits an unknown verb,
154
 
so that you can transform it into a known one.
155
 
<P>
156
 
 
157
 
<P>
158
 
The following constants, if defined in a game, change settings made by the
159
 
library.  Those described as "To indicate that...'' have no meaningful
160
 
value; one simply defines them by, e.g., the directive <TT>Constant DEBUG;</TT>.
161
 
<P>
162
 
 
163
 
<P>
164
 
<P>
165
 
 
166
 
<DT><B><TT>AMUSING_PROVIDED</TT></B><DD>
167
 
To indicate that an <TT>Amusing</TT> routine is provided.
168
 
<P>
169
 
 
170
 
<DT><B><TT>DEBUG</TT></B><DD>
171
 
To indicate that the special "debugging" verbs are to be
172
 
included.
173
 
<P>
174
 
 
175
 
<DT><B><TT>Headline</TT></B><DD>
176
 
Style of game and copyright message.
177
 
<P>
178
 
 
179
 
<DT><B><TT>MAX_CARRIED</TT></B><DD>
180
 
Maximum number of (direct) possessions the player can
181
 
carry.
182
 
<P>
183
 
 
184
 
<DT><B><TT>MAX_SCORE</TT></B><DD>
185
 
Maximum game score.
186
 
<P>
187
 
 
188
 
<DT><B><TT>MAX_TIMERS</TT></B><DD>
189
 
Maximum number of timers or daemons active at any one time
190
 
(defaults to 32).
191
 
<P>
192
 
 
193
 
<DT><B><TT>NO_PLACES</TT></B><DD>
194
 
To indicate that the "places'' and "objects'' verbs
195
 
should not be allowed.
196
 
<P>
197
 
 
198
 
<DT><B><TT>NUMBER_TASKS</TT></B><DD>
199
 
Number of 'tasks' to perform.
200
 
<P>
201
 
 
202
 
<DT><B><TT>OBJECT_SCORE</TT></B><DD>
203
 
Score for picking up a <TT>scored</TT> object for the first
204
 
time.
205
 
<P>
206
 
 
207
 
<DT><B><TT>ROOM_SCORE</TT></B><DD>
208
 
Score for visiting up a <TT>scored</TT> room for the first time.
209
 
<P>
210
 
 
211
 
<DT><B><TT>SACK_OBJECT</TT></B><DD>
212
 
Object which acts as a 'rucksack', into which the game
213
 
automatically tidies away things for the player.
214
 
<P>
215
 
 
216
 
<DT><B><TT>Story</TT></B><DD>
217
 
Story name, conventionally in CAPITAL LETTERS.
218
 
<P>
219
 
 
220
 
<DT><B><TT>TASKS_PROVIDED</TT></B><DD>
221
 
To indicate that "tasks'' are provided.
222
 
<P>
223
 
 
224
 
<DT><B><TT>WITHOUT_DIRECTIONS</TT></B><DD>
225
 
To indicate that the standard compass directions
226
 
are to be omitted.
227
 
</TABLE>
228
 
<HR><A HREF="contents.html">Contents</A> / <A HREF="sectionA9.html">Back</A> / <A HREF="sectionA11.html">Forward</A> <BR>
229
 
<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>