1
! WhatIs - Code to add "what is <object>" type commands
2
! Copyright 1996 A.C. Murie
3
! Version 1.0 (Nov 19, 1996)
5
! This code may be freely distributed and used in any
6
! program, commercial or otherwise. It would be nice if you
7
! give me some credit, but it is not required. Feel free to
8
! modify it if you want.
10
! If you want to contact me, sourcerer@starbug.southern.co.nz
11
! will be valid, at least until late 1997.
13
! "Bugs? They aren't bugs! They're undocumented features!" :)
15
! Purpose - The use can type "what is an <object>" and be given
16
! information about it. This is a simple way to make background
17
! information to the player without unwanted explanatory text
20
! As an example, Zork has a "what is a grue" style of command.
22
! Additionally, "who am I" can be used to show who the player
23
! is. This prints the player's short_name. This is of
24
! particular use in games where the player can change
25
! character, or plays a pre-defined character.
27
! Usage - Include this file after parser.h
29
! Give an object the 'queryable' attribute and the 'whatisit'
30
! property. 'whatisit' may be a string or a routine to print
31
! a description of the object.
33
! Any object that is in scope may be queryed
35
! Additionally, objects that do not appear in the game may be
36
! stored in the object 'QueryObjs'. They will be in scope
37
! all the time, and may be used for general game concepts
39
! As a final option, the action WhatIs may be used in an
40
! objects 'before' code to print the whatis text.
42
! Any query for an object that is not in scope, regardless of
43
! wether it actually exists or not. Thus, a query will not show
44
! if an object exists, or is merely not available at that time.
46
! In game - A player can type text in this format :
47
! ["what"|"who"] ["is"|"am"|"are"] <object>
50
! "what is a disintegrator"
52
! "what is the big green door"
54
! Restriction - A question mark must have a space between it and the last
55
! word of the sentence, or be part of the objects 'name'
61
[ IsAmAre w; w=NextWord(); if (w=='is' or 'am' or 'are') return 0; return -1; ];
62
[ WhatIsWhatSub; "What is what?"; ];
63
[ QueryTopic; while( NextWordStopped() ~= -1 ) ; return 1; ];
64
[ WhatisQSub; "Good question."; ];
68
if( ZRegion(player.short_name) == 2 or 3 )
70
PrintOrRun(player,short_name,1);
77
if( noun == player ) <<WhoAmI>>;
78
if( noun hasnt queryable ) "Good question.";
79
if( ZRegion(noun.whatisit) == 2 or 3 )
81
PrintOrRun(noun,whatisit);
88
if( scope_stage == 1 ) rfalse;
89
if( scope_stage == 2 )
91
ScopeWithin( QueryObjs );
96
Object QueryObjs "Queryable objects";
98
verb meta "who" "what"
99
* IsAmAre -> WhatIsWhat
100
* IsAmAre "I" -> WhoAmI
101
* IsAmAre "I?" -> WhoAmI
102
* IsAmAre "I" "?" -> WhoAmI
103
* IsAmAre scope=QueryScope -> WhatIs
104
* IsAmAre scope=QueryScope "?" -> WhatIs
105
* QueryTopic -> WhatisQ;