372dc569817c212c3c7ad14edc8172c8a88fc1dd
[ibg.git] / appendices / f.rst
1 ==============================
2  Appendix F -- Inform library
3 ==============================
4
5 .. |ADD| replace:: **+**
6
7 .. The ⊕ symbol doesn't work in LaTeX.
8
9 .. default-role:: samp
10
11 .. only:: html
12
13    .. image:: /images/picL.png
14       :align: left
15
16 .. raw:: latex
17
18    \dropcap{l}
19
20 ibrary files define Inform's model world, turning a conventional
21 programming language into a text adventure development system.  Here are
22 the library constants, variables and routines, the standard object
23 properties and attributes, the verb grammars and actions.
24
25 Library objects
26 ===============
27
28 `compass`
29   A `container` object holding the twelve direction objects `d_obj e_obj
30   in_obj n_obj ne_obj nw_obj out_obj s_obj se_obj sw_obj u_obj w_obj`.
31
32 `LibraryMessages`
33   If defined (between Includes of `Parser` and `VerbLib`), changes standard
34   library messages:
35
36   .. only:: html
37
38     | `Object LibraryMessages`
39     |   `with before [;`
40     |        `{action}: "{string}";`
41     |        `{action}: "{string}";`
42     |        `{action}: switch (lm_n) {`
43     |                `{value}: "{string}";`
44     |                `{value}: "{string}",`
45     |                    `(a) lm_o,".";`
46     |                `...`
47     |                `}`
48     |            `...`
49     |        `];`
50
51   .. todo::
52
53      Get this to work properly in LaTeX.  Currently get a 'too deeply
54      nested' error.
55
56 `selfobj`
57   The default player object.  Avoid: use instead the `player` variable,
58   which usually refers to `selfobj`.
59
60 `thedark`
61   A pseudo-room which becomes the `location` when there is no light
62   (although the player object is not moved there).
63
64 Library constants
65 =================
66
67 In addition to the standard constants `true` (1), `false` (0) and `nothing`
68 (0), the Library defines `NULL` (-1) for an `{action}`, `{property}` or
69 `{pronoun}` whose current value is undefined.
70
71 `LIBRARY_PARSER`, `LIBRARY_ENGLISH`, `LIBRARY_VERBLIB` and
72 `LIBRARY_GRAMMAR` are defined to mark the end of inclusion of `Parser.h`,
73 `English.h`, `VerbLib.h` and `Grammar.h` respectively.
74
75 User-defined constants
76 ======================
77
78 Some constants control features rather than represent values.
79
80 `AMUSING_PROVIDED`
81   Activates the `Amusing` entry point.
82
83 `COMMENT_CHARACTER = '{char}'`
84   Introduces a comment line ignored by the parser (default "*").
85
86 `DEATH_MENTION_UNDO`
87   Offers "UNDO the last move" at game end.
88
89 `DEBUG`
90   Activates the debug commands.
91
92 `Headline = "{string}"`
93   **Mandatory**: game style, copyright info, etc.
94
95 `MANUAL_PRONOUNS`
96   Pronouns reflect only objects mentioned by the player.
97
98 `MAX_CARRIED = {expr}`
99   Limit on direct possessions that the player can carry (default 100).
100
101 `MAX_SCORE = {expr}`
102   Maximum game score (default 0).
103
104 `MAX_TIMERS = {expr}`
105   Limit on active timers/daemons (default 32).
106
107 `NO_PLACES`
108   "`OBJECTS`" and "`PLACES`" verbs are barred.
109
110 `NO_SCORE`
111   Game doesn't use scoring.
112
113 `NUMBER_TASKS = {expr}`
114   Number of `scored` tasks (default 1).
115
116 `OBJECT_SCORE = {expr}`
117   For taking a `scored` object for the first time (default 4).
118
119 `ROOM_SCORE = {expr}`
120   For visiting a `scored` room for the first time (default 5).
121
122 `SACK_OBJECT = {obj_id}`
123   A `container` object where the game places held objects.
124
125 `START_MOVE = {expr}`
126   Initial value of turns counter (default 0).
127
128 `Story = "{string}"`
129   **Mandatory**: the name of the story.
130
131 `TASKS_PROVIDED`
132   Activates the task scoring system.
133
134 `USE_MODULES`
135   Activates linking with pre-compiled library modules.
136
137 `WITHOUT_DIRECTIONS`
138   De-activates standard compass directions (bar "`IN`" and "`OUT`").  Place
139   alternative directions in the `compass`.
140
141 Library variables
142 =================
143
144 `action`
145   The current `{action}`.
146
147 `actor`
148   The target of an instruction: the player, or an NPC.
149
150 `deadflag`
151   Normally 0: 1 indicates a regular death, 2 indicates that the player has
152   won, 3 or more denotes a user-defined end.
153
154 `inventory_stage`
155   Used by `invent` and `list_together` properties.
156
157 `keep_silent`
158   Normally `false`; `true` makes most group 2 actions silent.
159
160 `location`
161   The player's current room; unless that's dark, when it contains
162   `thedark`, `real_location` contains the room.
163
164 `notify_mode`
165   Normally `true`: `false` remains silent when score changes.
166
167 `noun`
168   The primary focus object for the current action.
169
170 `player`
171   The object acting on behalf of the human player.
172
173 `real_location`
174   The player's current room when in the dark.
175
176 `score`
177   The current score.
178
179 `second`
180   The secondary focus object for the current action.
181
182 `self`
183   The object which received a message.  (Note: a run-time variable, not a
184   compile-time constant.)
185
186 `sender`
187   The object which sent a message (or `nothing`).
188
189 `task_scores`
190   A byte array holding scores for the task scoring system.
191
192 `the_time`
193   The game's clock, in minutes 0..1439 since midnight.
194
195 `turns`
196   The game's turn counter.
197
198 `wn`
199   The input stream word number, counting from 1.
200
201 .. _library-routines:
202
203 Library routines
204 ================
205
206 `Achieved({expr})`
207   A scored task has been achieved.
208
209 `AfterRoutines()`
210   In a group 2 action, controls output of "after" messages.
211
212 `AllowPushDir()`
213   An object can be pushed from one location to another.
214
215 `Banner()`
216   Prints the game banner.
217
218 `ChangePlayer({obj_id,flag})`
219   Player assumes the persona of the `{obj_id}`.  If the optional `{flag}`
220   is `true`, room descriptions include "(as `{object}`)".
221
222 `CommonAncestor({obj_id1,obj_id2})`
223   Returns the nearest object which has a parental relationship to both
224   `{obj_ids}`, or `nothing`.
225
226 `DictionaryLookup({byte_array,length})`
227   Returns address of word in dictionary, or 0 if not found.
228
229 `DrawStatusLine()`
230   Refreshes the status line; happens anyway at end of each turn.
231
232 `GetGNAOfObject(obj_id)`
233   Returns gender-number-animation 0..11 of the `{obj_id}`.
234
235 `HasLightSource(obj_id)`
236   Returns `true` if the `{obj_id}` has light.
237
238 `IndirectlyContains({parnt_obj_id,obj_id})`
239   Returns `true` if `{obj_id}` is currently a child or grand-child or
240   great-grand-child... of the `{parent_object}`.
241
242 `IsSeeThrough(obj_id)`
243   Returns `true` if light can pass through the `{obj_id}`.
244
245 `Locale({obj_id,"string1","string2"})`
246   Describes the contents of `{obj_id}`, and returns their number.  After
247   objects with own paragraphs, the rest are listed preceded by `{string1}`
248   or `{string2}`.
249
250 `LoopOverScope({routine_id,actor})`
251   Calls `{routine_id}({obj_id})` for each `{obj_id}` in scope.  If the
252   optional `{actor}` is supplied, that defines the scope.
253
254 `MoveFloatingObjects()`
255   Adjusts positions of game's `found_in` objects.
256
257 `NextWord()`
258   Returns the next dictionary word in the input stream, incrementing `wn`
259   by one.  Returns `false` if the word is not in the dictionary, or if the
260   input stream is exhausted.
261
262 `NextWordStopped()`
263   Returns the next dictionary word in the input stream, incrementing `wn`
264   by one.  Returns `false` if the word is not in the dictionary, -1 if the
265   input stream is exhausted.
266
267 `NounDomain({obj_id1,obj_id2,type})`
268   Performs object parsing; see also `ParseToken()`.
269
270 `ObjectIsUntouchable({obj_id,flag})`
271   Tests whether there is a barrier - a container object which is not open -
272   between player and `{obj_id}`.  Unless the optional `{flag}` is `true`,
273   outputs "You can't because ... is in the way".  Returns `true` is a
274   barrier is found, otherwise `false`.
275
276 `OffersLight({obj_id})`
277   Returns `true` if the `{obj_id}` offers light.
278
279 `ParseToken({type,value})`
280   Performs general parsing; see also `NounDomain()`.
281
282 `PlaceInScope({obj_id})`
283   Used in an `add_to_scope` property or `scope=` token to put the
284   `{obj_id}` into scope for the parser.
285
286 `PlayerTo({obj_id,flag})`
287   Moves the player to `{obj_id}`.  Prints its description unless optional
288   `{flag}` is 1 (no description) or 2 (as if walked in).
289
290 `PrintOrRun({obj_id,property,flag})`
291   If `{obj_id.property}` is a string, output it (followed by a newline
292   unless optional `{flag}` is `true`), and return `true`.  If it's a
293   routine, run it and return what the routine returns.
294
295 `PronounNotice({obj_id})`
296   Associates an appropriate pronoun with the `{obj_id}`.
297
298 `PronounValue('{pronoun}')`
299   Returns the object to which '`it`' (or '`him`', '`her`', '`them`')
300   currently refers, or `nothing`.
301
302 `ScopeWithin({obj_id})`
303   Used in an `add_to_scope` property or `scope=` token to put the contents
304   of the `{obj_id}` in scope for the parser.
305
306 `SetPronoun('{pronoun}',{obj_id})`
307   Defines the `{obj_id}` to which a given pronoun refers.
308
309 `SetTime({expr1,expr2})`
310
311   Sets `the_time` to `{expr1}` (in mins 0..1439 since midnight), running at
312   `{expr2}` -
313
314   | +ve: `{expr2}` minutes pass each turn;
315   | -ve: `{-expr2}` turns take one minute;
316   | zero: time stands still.
317
318 `StartDaemon({obj_id})`
319   Starts the `{obj_id}`\'s daemon.
320
321 `StartTimer({obj_id,expr})`
322   Starts the `{obj_id}`\'s timer, initialising its `time_left` to `{expr}`.
323   The object's `time_out` property will be called after that number of
324   turns have elapsed.
325
326 `StopDaemon({obj_id})`
327   Stops the `{obj_id}`\'s daemon.
328
329 `StopTimer({obj_id})`
330   Stops the `{obj_id}`\'s timer.
331
332 `TestScope({obj_id,actor})`
333   Returns `true` if the `{obj_id}` is in scope, otherwise `false`.  If the
334   optional `{actor}` is supplied, that defines the scope.
335
336 `TryNumber({expr})`
337   Parses word `{expr}` in the input stream as a number, recognising
338   decimals, also English words one..twenty.  Returns the number 1..10000,
339   or -1000 if the parse fails.
340
341 `UnsignedCompare({expr1,expr2})`
342   Returns -1 if `{expr1}` is less than `{expr2}`, 0 if `{expr1}` equals
343   `{expr2}`, and 1 if `{expr1}` is greater than `{expr2}`.  Both
344   expressions are unsigned, in the range 0..65535.
345
346 `WordAddress({expr})`
347   Returns a byte array containing the raw text of word `{expr}` in the
348   input stream.
349
350 `WordInProperty({word,obj_id,property})`
351   Returns `true` if the dictionary `{word}` is listed in the `{property}`
352   values for the `{obj_id}`.
353
354 `WordLength({expr})`
355   Returns the length of word `{expr}` in the input stream.
356
357 `WriteListFrom({obj_id,expr})`
358   Outputs a list of `{obj_id}` and its siblings, in the given style, an
359   `{expr}` formed by adding any of: `ALWAYS_BIT`, `CONCEAL_BIT`,
360   `DEFART_BIT`, `ENGLISH_BIT`, `FULLINV_BIT`, `INDENT_BIT`, `ISARE_BIT`,
361   `NEWLINE_BIT`, `PARTINV_BIT`, `RECURSE_BIT`, `TERSE_BIT`, `WORKFLAG_BIT`.
362
363 `YesOrNo()`
364   Returns `true` if the player types "`YES`", `false` for "`NO`".
365
366 `ZRegion({arg})`
367   Returns the type of its `{arg}` : 3 for a string address, 2 for a routine
368   address, 1 for an object number, or 0 otherwise.
369
370 .. _object-props:
371
372 Object properties
373 =================
374
375 Where the `value` of a property can be a routine, several formats are
376 possible (but remember: embedded "`]`" returns `false`, standalone "`]`"
377 returns `true`):
378
379   | `{property} [; {stmt}; {stmt}; ... ]`
380   | `{property} [; return {routine_id}(); ]`
381   | `{property} [; {routine_id}(); ]`
382   | `{property} {routine_id}`
383
384 In this appendix, |ADD| marks an additive property.  Where a `Class` and an
385 `Object` of that class both define the same property, the value specified
386 for the `Object` normally overrides the value inherited from the `Class`.
387 However, if the property is additive then both values apply, with the
388 Object's value being considered first.
389
390 `add_to_scope`
391   For an object: additional objects which follow it in and out of scope.
392   The `{value}` can be a space-separated list of `{obj_ids}`, or a routine
393   which invokes `PlaceInScope()` or `ScopeWithin()` to specify objects.
394
395 `after` |ADD|
396   For an object: receives every `{action}` and `{fake_action}` for which
397   this is the `{noun}`.  For a room: receives every `{action}` which occurs
398   here.
399
400   The `{value}` is a routine of structure similar to a `switch` statement,
401   having cases for the appropriate `{actions}` (and an optional `default`
402   as well); it is invoked after the action has happened, but before the
403   player has been informed.  The routine should return `false` to continue,
404   telling the player what has happened, or `true` to stop processing the
405   action and produce no further output.
406
407 `article`
408   For an object: the object's indefinite article - the default is
409   automatically "a", "an" or "some".  The `{value}` can be a string, or a
410   routine which outputs a string.
411
412 `articles`
413   For a non-English object: its definite and indefinite articles.  The
414   `{value}` is an array of strings.
415
416 `before` |ADD|
417   For an object: receives every `{action}` and `{fake_action}` for which
418   this is the `{noun}`.  For a room: receives every action which occurs
419   here.
420
421   The `{value}` is a routine invoked before the action has happened.  See
422   `after`.
423
424 `cant_go`
425   For a room: the message when the player attempts an impossible exit.  The
426   `{value}` can be a string, or a routine which outputs a string.
427
428 `capacity`
429   For a `container` or `supporter` object: the number of objects which can
430   be placed in or on it - the default is 100.
431
432   For the player: the number which can be carried - `selfobj` has an
433   initial capacity of `MAX_CARRIED`.
434
435   The `{value}` can be a number, or a routine which returns a number.
436
437 `d_to`
438   For a room: a possible exit.  The `{value}` can be
439
440   * `false` (the default): not an exit;
441   * a string: output to explain why this is not an exit;
442   * a `{room}`: the exit leads to this room;
443   * a `door` object: the exit leads through this door;
444   * a routine which should return `false`, a string, a `{room}`, a `door`
445     object, or `true` to signify "not an exit" and produce no further
446     output.
447
448 `daemon`
449   The `{value}` is a routine which can be activated by
450   `StartDaemon({obj_id})` and which then runs once each turn until
451   deactivated by `StopDaemon({obj_id})`.
452
453 `describe` |ADD|
454   For an object: called before the object's description is output.  For a
455   room: called before the room's (long) description is output.
456
457   The `{value}` is a routine which should return `false` to continue,
458   outputting the usual description, or `true` to stop processing and
459   produce no further output.
460
461 `description`
462   For an object: its description (output by `Examine`).
463
464   For a room: its long description (output by `Look`).
465
466   The `{value}` can be a string, or a routine which outputs a string.
467
468 `door_dir`
469   For a `compass` object (`d_obj`, `e_obj`, ...): the direction in which an
470   attempt to move to this object actually leads.
471
472   For a `door` object: the direction in which this door leads.
473
474   The `{value}` can be a directional property (`d_to`, `e_to`, ...), or a
475   routine which returns such a property.
476
477 `door_to`
478   For a `door` object: where it leads.  The value can be
479
480   * `false` (the default): leads nowhere;
481   * a string: output to explain why door leads nowhere;
482   * a `{room}`: the door leads to this room;
483   * a routine which should return `false`, a string, a `{room}`, or `true`
484     to signify "leads nowhere" without producing any output.
485
486 `e_to`
487   See `d_to`.
488
489 `each_turn` |ADD|
490   Invoked at the end of each turn (after all appropriate daemons and
491   timers) whenever the object is in scope.  The `{value}` can be a string,
492   or a routine.
493
494 `found_in`
495   For an object: the rooms where this object can be found, unless it has
496   the `absent` attribute.  The `{value}` can be
497
498   * a space-separated list of `{rooms}` (where this object can be found) or
499      `{obj_ids}` (whose locations are tracked by this object);
500   * a routine which should return `true` if this object can be found in the
501      current location, otherwise `false`.
502
503 `grammar`
504   For an `animate` or `talkable` object: the `{value}` is a routine called
505   when the parser knows that this object is being addressed, but has yet to
506   test the grammar.  The routine should return `false` to continue, `true`
507   to indicate that the routine has parsed the entire command, or a
508   dictionary word ('`word`' or -'`word`').
509
510 `in_to`
511   See `d_to`.
512
513 `initial`
514   For an object: its description before being picked up.
515
516   For a room: its description when the player enters the room.
517
518   The `{value}` can be a string, or a routine which outputs a string.
519
520 `inside_description`
521   For an `enterable` object: its description, output as part of the room
522   description when the player is inside the object.
523
524   The `{value}` can be a string, or a routine which outputs a string.
525
526 `invent`
527   For an object: the `{value}` is a routine for outputting the object's
528   inventory listing, which is called twice.  On the first call nothing has
529   been output; `inventory_stage` has the value 1, and the routine should
530   return `false` to continue, or `true` to stop processing and produce no
531   further output.  On the second call the object's indefinite article and
532   short name have been output, but not any subsidiary information;
533   `inventory_stage` has the value 2, and the routine should return `false`
534   to continue, or `true` to stop processing and produce no further output.
535
536 `life` |ADD|
537   For an `animate` object: receives person-to-person actions (`Answer`,
538   `Ask`, `Attack`, `Give`, `Kiss`, `Order`, `Show`, `Tell`, `ThrowAt` and
539   `WakeOther`) for which this is the `{noun}`.  The `{value}` is a routine
540   of structure similar to a `switch` statement, having cases for the
541   appropriate `{actions}` (and an optional default as well).  The routine
542   should return `false` to continue, telling the player what has happened,
543   or `true` to stop processing the action and produce no further output.
544
545 `list_together`
546
547   For an object: groups related objects when outputting an inventory or
548   room contents list.  The `{value}` can be
549
550   * a `{number}`: all objects having this value are grouped;
551   * a `{string}`: all objects having this value are grouped as a count of
552     the string;
553   * a routine which is called twice.  On the first call nothing has been
554     output; `inventory_stage` has the value 1, and the routine should
555     return `false` to continue, or `true` to stop processing and produce no
556     further output.  On the second call the list has been output;
557     `inventory_stage` has the value 2, and there is no test on the return
558     value.
559
560 `n_to`
561   See `d_to`.
562
563 `name` |ADD|
564   Defines a space-separated list of words which are added to the Inform
565   dictionary.  Each word can be supplied in apostrophes '...'  or quotes
566   "..."; in all other cases only words in apostrophes update the
567   dictionary.
568
569   For an object: identifies this object.
570
571   For a room: outputs "does not need to be referred to".
572
573 `ne_to`
574   See `d_to`.
575
576 `number`
577   For an object or room: the `{value}` is a general-purpose variable freely
578   available for use by the program.  A `player` object must provide (but
579   not use) this variable.
580
581 `nw_to`
582   See `d_to`.
583
584 `orders` |ADD|
585   For an `animate` or `talkable` object: the `{value}` is a routine called
586   to carry out the player's orders.  The routine should return `false` to
587   continue, or `true` to stop processing the action and produce no further
588   output.
589
590 `out_to`
591   See `d_to`.
592
593 `parse_name`
594   For an object: the `{value}` is a routine called to parse an object's
595   name.  The routine should return zero if the text makes no sense, -1 to
596   cause the parser to resume, or the positive number of words matched.
597
598 `plural`
599   For an object: its plural form, when in the presence of others like it.
600   The `{value}` can be a string, or a routine which outputs a string.
601
602 `react_after`
603   For an object: detects nearby actions - those which take place when this
604   object is in scope.  The `{value}` is a routine invoked after the action
605   has happened, but before the player has been informed.  See `after`.
606
607 `react_before`
608   For an object: detects nearby actions - those which take place when this
609   object is in scope.  The `{value}` is a routine invoked before the action
610   has happened.  See `after`.
611
612 `s_to`
613
614 `se_to`
615   See `d_to`.
616
617 `short_name`
618   For an object: an alternative or extended short name.  The `{value}` can
619   be a string, or a routine which outputs a string.  The routine should
620   return `false` to continue by outputting the object's *actual* short name
621   (from the head of the object definition), or `true` to stop processing
622   the action and produce no further output.
623
624 `short_name_indef`
625   For a non-English object: the short name when preceded by an indefinite
626   object.  The `{value}` can be a string, or a routine which outputs a
627   string.
628
629 `sw_to`
630   See `d_to`.
631
632 `time_left`
633   For a timer object: the `{value}` is a variable to hold the number of
634   turns left until this object's timer - activated and initialised by
635   `StartTimer({obj_id})` - counts down to zero and invokes the object's
636   `time_out` property.
637
638 `time_out`
639   For a timer object: the `{value}` is a routine which is run when the
640   object's `time_left` value - initialised by `StartTimer({obj_id})`, and
641   not in the meantime cancelled by `StopTimer({obj_id})` - counts down to
642   zero.
643
644 `u_to`
645
646 `w_to`
647   See `d_to`.
648
649 `when_closed`
650
651 `when_open`
652   For a `container` or `door` object: used when including this object in a
653   room's long description.  The `{value}` can be a string, or a routine
654   which outputs a string.
655
656 `when_off`
657
658 `when_on`
659   For a `switchable` object: used when including this object in a room's
660   long description.  The `{value}` can be a string, or a routine which
661   outputs a string.
662
663 `with_key`
664   For a `lockable` object: the `{obj_id}` (generally some kind of key)
665   needed to lock and unlock the object, or `nothing` if no key fits.
666
667 .. _object-attrs:
668
669 Object attributes
670 =================
671
672 `absent`
673      For a floating object (one with a `found_in` property, which can
674      appear in many rooms): is no longer there.
675
676 `animate`
677      For an object: is a living creature.
678
679 `clothing`
680      For an object: can be worn.
681
682 `concealed`
683      For an object: is present but hidden from view.
684
685 `container`
686      For an object: other objects can be put in (but not on) it.
687
688 `door`
689      For an object: is a door or bridge between rooms.
690
691 `edible`
692      For an object: can be eaten.
693
694 `enterable`
695      For an object: can be entered.
696
697 `female`
698      For an `animate` object: is female.
699
700 `general`
701      For an object or room: a general-purpose flag.
702
703 `light`
704      For an object or room: is giving off light.
705
706 `lockable`
707      For an object: can be locked; see the `with_key` property.
708
709 `locked`
710      For an object: can't be opened.
711
712 `male`
713      For an `animate` object: is male.
714
715 `moved`
716      For an object: is being, or has been, taken by the player.
717
718 `neuter`
719      For an `animate` object: is neither male nor female.
720
721 `on`
722      For a `switchable` object: is switched on.
723
724 `open`
725      For a `container` or door object: is open.
726
727 `openable`
728      For a `container` or `door` object: can be opened.
729
730 `pluralname`
731      For an object: is plural.
732
733 `proper`
734      For an object: the short name is a proper noun, therefore not to be
735      preceded by "The" or "the".
736
737 `scenery`
738      For an object: can't be taken; is not listed in a room description.
739
740 `scored`
741      For an object: awards `OBJECT_SCORE` points when taken for the first
742      time.  For a room: awards `ROOM_SCORE` points when visited for the
743      first time.
744
745 `static`
746      For an object: can't be taken.
747
748 `supporter`
749      For an object: other objects can be put on (but not in) it.
750
751 `switchable`
752      For an object: can be switched off or on.
753
754 `talkable`
755      For an object: can be addressed in "object, do this" style.
756
757 `transparent`
758      For a `container` object: objects inside it are visible.
759
760 `visited`
761      For a room: is being, or has been, visited by the player.
762
763 `workflag`
764      Temporary internal flag, also available to the program.
765
766 `worn`
767      For a `clothing` object: is being worn.
768
769 .. _entry-points:
770
771 Optional entry points
772 =====================
773
774 These routines, if you supply them, are called when shown.
775
776 `AfterLife()`
777   Player has died; `deadflag=0` resurrects.
778
779 `AfterPrompt()`
780   The ">" prompt has been output.
781
782 `Amusing()`
783   Player has won; `AMUSING_PROVIDED` is defined.
784
785 `BeforeParsing()`
786   The parser has input some text, set up the buffer and parse tables, and
787   initialised `wn` to 1.
788
789 `ChooseObjects({object,flag})`
790   Parser has found "`ALL`" or an ambiguous noun phrase and decided that
791   `{object}` should be excluded (`flag` is 0), or included (`flag` is 1).
792   The routine should return 0 to let this stand, 1 to force inclusion, or 2
793   to force exclusion.  If `flag` is 2, parser is undecided; routine should
794   return appropriate score 0..9.
795
796 `DarkToDark()`
797   The player has gone from one dark room to another.
798
799 `DeathMessage()`
800   The player has died; `deadflag` is 3 or more.
801
802 `GamePostRoutine()`
803   Called after all actions.
804
805 `GamePreRoutine()`
806   Called before all actions.
807
808 `Initialise()`
809   **Mandatory; note British spelling**: called at start.  Must set
810   `location`; can return 2 to suppress game banner.
811
812 `InScope()`
813   Called during parsing.
814
815 `LookRoutine()`
816   Called at the end of every `Look` description.
817
818 `NewRoom()`
819   Called when room changes, before description is output.
820
821 `ParseNoun({object})`
822   Called to parse the `{object}`\'s name.
823
824 `ParseNumber({byte_array,length})`
825   Called to parse a number.
826
827 `ParserError({number})`
828   Called to handle an error.
829
830 `PrintRank()`
831   Completes the output of the score.
832
833 `PrintTaskName({number})`
834   Prints the name of the task.
835
836 `PrintVerb({addr})`
837   Called when an unusual verb is printed.
838
839 `TimePasses()`
840   Called after every turn.
841
842 `UnknownVerb()`
843   Called when an unusual verb is encountered.
844
845 .. _group-1-actions:
846
847 Group 1 actions
848 ===============
849
850 Group 1 actions support the 'meta' verbs.  These are the standard actions
851 and their triggering verbs.
852
853 ==============  =====================================================
854 `CommandsOff`   "`RECORDING OFF`"
855 `CommandsOn`    "`RECORDING [ON]`"
856 `CommandsRead`  "`REPLAY`"
857 `FullScore`     "`FULLSCORE`", "`FULL [SCORE]`"
858 `LMode1`        "`BRIEF`", "`NORMAL`"
859 `LMode2`        "`LONG`", "`VERBOSE`"
860 `LMode3`        "`SHORT`", "`SUPERBRIEF`"
861 `NotifyOff`     "`NOTIFY OFF`"
862 `NotifyOn`      "`NOTIFY [ON]`"
863 `Objects`       "`OBJECTS`"
864 `Places`        "`PLACES`"
865 `Pronouns`      "`[PRO]NOUNS`"
866 `Quit`          "`DIE`", "`Q[UIT]`"
867 `Restart`       "`RESTART`"
868 `Restore`       "`RESTORE`"
869 `Save`          "`CLOSE`"
870 `Score`         "`SCORE`"
871 `ScriptOff`     "`[TRAN]SCRIPT OFF`", "`NOSCRIPT`", "`UNSCRIPT`"
872 `ScriptOn`      "`[TRAN]SCRIPT [ON]`"
873 `Verify`        "`VERIFY`"
874 `Version`       "`VERSION`"
875 ==============  =====================================================
876
877 and the debug tools.
878
879 ===============   ===================================================
880 `ActionsOff`      "`ACTIONS OFF`"
881 `ActionsOn`       "`ACTIONS [ON]`"
882 `ChangesOff`      "`CHANGES OFF`"
883 `ChangesOn`       "`CHANGES [ON]`"
884 `Gonear`          "`GONEAR`"
885 `Goto`            "`GOTO`"
886 `Predictable`     "`RANDOM`"
887 `RoutinesOff`     "`MESSAGES OFF`", "`ROUTINES OFF`"
888 `RoutinesOn`      "`MESSAGES [ON]`", "`ROUTINES [ON]`"
889 `Scope`           "`SCOPE`"
890 `Showobj`         "`SHOWOBJ`"
891 `Showverb`        "`SHOWVERB`"
892 `TimersOff`       "`DAEMONS OFF`", "`TIMERS OFF`"
893 `TimersOn`        "`DAEMONS [ON]`", "`TIMERS [ON]`"
894 `TraceLevel`      "`TRACE number`"
895 `TraceOff`        "`TRACE OFF`"
896 `TraceOn`         "`TRACE [ON]`"
897 `XAbstract`       "`ABSTRACT`"
898 `XPurloin`        "`PURLOIN`"
899 `XTree`           "`TREE`"
900 ===============   ===================================================
901
902 .. _group-2-actions:
903
904 Group 2 actions
905 ===============
906
907 Group 2 actions usually work, given the right circumstances.
908
909 =============   =============================================================
910 `Close`         "`CLOSE [UP]`", "`COVER [UP]`", "`SHUT [UP]`"
911 `Disrobe`       "`DISROBE`", "`DOFF`", "`REMOVE`", "`SHED`", "`TAKE OFF`"
912 `Drop`          "`DISCARD`", "`DROP`", "`PUT DOWN`", "`THROW`"
913 `Eat`           "`EAT`"
914 `Empty`         "`EMPTY [OUT]`"
915 `EmptyT`        "`EMPTY IN|INTO|ON|ONTO|TO`"
916 `Enter`         "`CROSS`", "`ENTER`", "`GET IN|INTO|ON|ONTO`",
917                 "`GO IN|INSIDE|INTO|THROUGH`",
918                 "`LEAVE IN|INSIDE|INTO|THROUGH`", "`LIE IN|INSIDE|ON`",
919                 "`LIE ON TOP OF`",
920                 "`RUN IN|INSIDE|INTO|THROUGH`", "`SIT IN|INSIDE|ON`",
921                 "`SIT ON TOP OF`", "`STAND ON`",
922                 "`WALK IN|INSIDE|INTO|THROUGH`"
923 `Examine`       "`CHECK,`" "`DESCRIBE`", "`EXAMINE`",
924                 "`L[OOK] AT`", "`READ`", "`WATCH`", "`X`"
925 `Exit`          "`EXIT`", "`GET OFF|OUT|UP`",
926                 "`LEAVE`", "`OUT[SIDE]`", "`STAND [UP]`"
927 `GetOff`        "`GET OFF`"
928 `Give`          "`FEED [TO]`", "`GIVE [TO]`", "`OFFER [TO]`", "`PAY [TO]`"
929 `Go`            "`GO`", "`LEAVE`", "`RUN`", "`WALK`"
930 `GoIn`          "`CROSS`", "`ENTER`", "`IN[SIDE]`"
931 `Insert`        "`DISCARD IN|INTO`",
932                 "`DROP DOWN|IN|INTO`",
933                 "`INSERT IN|INTO`",
934                 "`PUT IN|INSIDE|INTO`",
935                 "`THROW DOWN|IN|INTO`"
936 `Inv`           "`I[NV]`", "`INVENTORY`", "`TAKE INVENTORY`"
937 `InvTall`       "`I[NV] TALL`", "`INVENTORY TALL`"
938 `InvWide`       "`I[NV] WIDE`", "`INVENTORY WIDE`"
939 `Lock`          "`LOCK WITH`"
940 `Look`          "`L[OOK]`"
941 `Open`          "`OPEN`", "`UNCOVER`", "`UNDO`", "`UNWRAP`"
942 `PutOn`         "`DISCARD ON|ONTO`",
943                 "`DROP ON|ONTO`",
944                 "`PUT ON|ONTO`",
945                 "`THROW ON|ONTO`"
946 `Remove`        "`GET FROM`", "`REMOVE FROM`", "`TAKE FROM|OFF`"
947 `Search`        "`L[OOK] IN|INSIDE|INTO|THROUGH`", "`SEARCH`"
948 `Show`          "`DISPLAY [TO]`", "`PRESENT [TO]`", "`SHOW [TO]`"
949 `SwitchOff`     "`CLOSE OFF`", "`SCREW OFF`",
950                 "`SWITCH OFF`", "`TURN OFF`",
951                 "`TWIST OFF`"
952 `SwitchOn`      "`SCREW ON`", "`SWITCH ON`",
953                 "`TURN ON`", "`TWIST ON`"
954 `Take`          "`CARRY`", "`GET`", "`HOLD`",
955                 "`PEEL [OFF]`", "`PICK UP`",
956                 "`REMOVE`", "`TAKE`"
957 `Transfer`      "`CLEAR TO`", "`MOVE TO`",
958                 "`PRESS TO`", "`PUSH TO`",
959                 "`SHIFT TO`", "`TRANSFER TO`"
960 `Unlock`        "`OPEN WITH`", "`UNDO WITH`",
961                 "`UNLOCK WITH`"
962 `VagueGo`       "`GO`", "`LEAVE`", "`RUN`", "`WALK`"
963 `Wear`          "`DON`", "`PUT ON`", "`WEAR`"
964 =============   =============================================================
965
966 .. _group-3-actions:
967
968 Group 3 actions
969 ===============
970
971 Group 3 actions are by default stubs which output a message and stop at the
972 "before" stage (so there is no "after" stage).
973
974 =============   =============================================================
975 `Answer`        "`ANSWER TO`", "`SAY TO`",
976                 "`SHOUT TO`", "`SPEAK TO`"
977 `Ask`           "`ASK ABOUT`"
978 `AskFor`        "`ASK FOR`"
979 `Attack`        "`ATTACK`", "`BREAK`", "`CRACK`",
980                 "`DESTROY`", "`FIGHT`", "`HIT`",
981                 "`KILL`", "`MURDER`", "`PUNCH`",
982                 "`SMASH`", "`THUMP`", "`TORTURE`",
983                 "`WRECK`"
984 `Blow`          "`BLOW`"
985 `Burn`          "`BURN [WITH]`", "`LIGHT [WITH]`"
986 `Buy`           "`BUY`" "`PURCHASE`"
987 `Climb`         "`CLIMB [OVER|UP]`", "`SCALE`"
988 `Consult`       "`CONSULT ABOUT|ON`",
989                 "`LOOK UP IN`",
990                 "`READ ABOUT IN`", "`READ IN`"
991 `Cut`           "`CHOP,`" "`CUT`", "`PRUNE`", "`SLICE`"
992 `Dig`           "`DIG [WITH]`"
993 `Drink`         "`DRINK`", "`SIP`", "`SWALLOW`"
994 `Fill`          "`FILL`"
995 `Jump`          "`HOP`", "`JUMP`", "`SKIP`"
996 `JumpOver`      "`HOP OVER`", "`JUMP OVER`", "`SKIP OVER`"
997 `Kiss`          "`EMBRACE`", "`HUG`", "`KISS`"
998 `Listen`        "`HEAR`", "`LISTEN [TO]`"
999 `LookUnder`     "`LOOK UNDER`"
1000 `Mild`          Various mild swearwords.
1001 `No`            "`NO`"
1002 `Pray`          "`PRAY`"
1003 `Pull`          "`DRAG`" "`PULL`"
1004 `Push`          "`CLEAR`", "`MOVE`", "`PRESS`",
1005                 "`PUSH`", "`SHIFT`"
1006 `PushDir`       "`CLEAR`", "`MOVE`", "`PRESS`",
1007                 "`PUSH`", "`SHIFT`"
1008 `Rub`           "`CLEAN`", "`DUST`", "`POLISH`",
1009                 "`RUB`", "`SCRUB`", "`SHINE`",
1010                 "`SWEEP`", "`WIPE`"
1011 `Set`           "`ADJUST`", "`SET`"
1012 `SetTo`         "`ADJUST TO`", "`SET TO`"
1013 `Sing`          "`SING`"
1014 `Sleep`         "`NAP`", "`SLEEP`"
1015 `Smell`         "`SMELL`", "`SNIFF`"
1016 `Sorry`         "`SORRY`"
1017 `Squeeze`       "`SQUASH`", "`SQUEEZE`"
1018 `Strong`        Various strong swearwords.
1019 `Swim`          "`DIVE`", "`SWIM`"
1020 `Swing`         "`SWING [ON]`"
1021 `Taste`         "`TASTE`"
1022 `Tell`          "`TELL ABOUT`"
1023 `Think`         "`THINK`"
1024 `ThrowAt`       "`THROW AGAINST|AT|ON|ONTO`"
1025 `Tie`           "`ATTACH [TO]`", "`FASTEN [TO]`",
1026                 "`FIX [TO]`", "`TIE [TO]`"
1027 `Touch`         "`FEEL,`" "`FONDLE`", "`GROPE`", "`TOUCH`"
1028 `Turn`          "`ROTATE`", "`SCREW`", "`TURN`",
1029                 "`TWIST`", "`UNSCREW`"
1030 `Wait`          "`WAIT`" "`Z`"
1031 `Wake`          "`AWAKE[N]`", "`WAKE [UP]`"
1032 `WakeOther`     "`AWAKE[N]`", "`WAKE [UP]`"
1033 `Wave`          "`WAVE`"
1034 `WaveHands`     "`WAVE`"
1035 `Yes`           "`Y[ES]`"
1036 =============   =============================================================
1037
1038 Fake actions
1039 ============
1040
1041 Fake actions handle some special cases, or represent "real" actions from
1042 the viewpoint of the second object.
1043
1044 ================   ========================================================
1045 `LetGo`            Generated by `Remove`.
1046 `ListMiscellany`   Outputs a range of inventory messages.
1047 `Miscellany`       Outputs a range of utility messages.
1048 `NotUnderstood`    Generated when parser fails to interpret some `orders`.
1049 `Order`            Receives things not handled by `orders`.
1050 `PluralFound`      Tells the parser that `parse_name()` has identified a
1051                    plural object.
1052 `Prompt`           Outputs the prompt, normally ">".
1053 `Receive`          Generated by `Insert` and `PutOn`.
1054 `TheSame`          Generated when parser can't distinguish between two
1055                    objects.
1056 `ThrownAt`         Generated by `ThrowAt`.
1057 ================   ========================================================