1
<HTML><HEAD><TITLE>Section A10: Entry points and meaningful constants</TITLE></HEAD>
2
<BODY BGCOLOR="#FFFFFF">
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
12
<DT><B><TT>AfterLife</TT></B><DD>
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
20
<DT><B><TT>AfterPrompt</TT></B><DD>
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.
27
<DT><B><TT>Amusing</TT></B><DD>
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
35
<DT><B><TT>BeforeParsing</TT></B><DD>
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.
44
<DT><B><TT>ChooseObjects(obj,c)</TT></B><DD>
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>.
56
<DT><B><TT>DarkToDark</TT></B><DD>
58
Called when a player goes from one dark room into another one; a splendid
59
excuse to kill the player off.
62
<DT><B><TT>DeathMessage</TT></B><DD>
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.)
68
<DT><B><TT>GamePostRoutine</TT></B><DD>
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.
74
<DT><B><TT>GamePreRoutine</TT></B><DD>
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.
80
<DT><B><TT>Initialise</TT></B><DD>
82
A compulsory routine, which must set <TT>location</TT> and is convenient for
83
miscellaneous initialising, perhaps for random settings.
86
<DT><B><TT>InScope</TT></B><DD>
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.
93
<DT><B><TT>LookRoutine</TT></B><DD>
95
Called at the end of every <TT>Look</TT> description.
98
<DT><B><TT>NewRoom</TT></B><DD>
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.
105
<DT><B><TT>ParseNoun(obj)</TT></B><DD>
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.
112
<DT><B><TT>ParseNumber(text,n)</TT></B><DD>
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>.
118
<DT><B><TT>ParserError(pe)</TT></B><DD>
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>).
124
<DT><B><TT>PrintRank</TT></B><DD>
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.
131
<DT><B><TT>PrintVerb(v)</TT></B><DD>
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.
139
<DT><B><TT>PrintTaskName(n)</TT></B><DD>
141
Prints the name of task <TT>n</TT> (such as "driving the car").
144
<DT><B><TT>TimePasses</TT></B><DD>
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.
151
<DT><B><TT>UnknownVerb</TT></B><DD>
153
Called by the parser when it hits an unknown verb,
154
so that you can transform it into a known one.
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>.
166
<DT><B><TT>AMUSING_PROVIDED</TT></B><DD>
167
To indicate that an <TT>Amusing</TT> routine is provided.
170
<DT><B><TT>DEBUG</TT></B><DD>
171
To indicate that the special "debugging" verbs are to be
175
<DT><B><TT>Headline</TT></B><DD>
176
Style of game and copyright message.
179
<DT><B><TT>MAX_CARRIED</TT></B><DD>
180
Maximum number of (direct) possessions the player can
184
<DT><B><TT>MAX_SCORE</TT></B><DD>
188
<DT><B><TT>MAX_TIMERS</TT></B><DD>
189
Maximum number of timers or daemons active at any one time
193
<DT><B><TT>NO_PLACES</TT></B><DD>
194
To indicate that the "places'' and "objects'' verbs
195
should not be allowed.
198
<DT><B><TT>NUMBER_TASKS</TT></B><DD>
199
Number of 'tasks' to perform.
202
<DT><B><TT>OBJECT_SCORE</TT></B><DD>
203
Score for picking up a <TT>scored</TT> object for the first
207
<DT><B><TT>ROOM_SCORE</TT></B><DD>
208
Score for visiting up a <TT>scored</TT> room for the first time.
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.
216
<DT><B><TT>Story</TT></B><DD>
217
Story name, conventionally in CAPITAL LETTERS.
220
<DT><B><TT>TASKS_PROVIDED</TT></B><DD>
221
To indicate that "tasks'' are provided.
224
<DT><B><TT>WITHOUT_DIRECTIONS</TT></B><DD>
225
To indicate that the standard compass directions
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 © Graham Nelson 1993, 1994, 1995, 1996, 1997: all rights reserved.</I></SMALL></BODY></HTML>