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

« back to all changes in this revision

Viewing changes to inform-6.31.1/include/whatis.h

  • 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
! WhatIs    - Code to add "what is <object>" type commands
 
2
!             Copyright 1996 A.C. Murie
 
3
!             Version 1.0 (Nov 19, 1996)
 
4
!
 
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.
 
9
!
 
10
!             If you want to contact me, sourcerer@starbug.southern.co.nz
 
11
!             will be valid, at least until late 1997.
 
12
!
 
13
!             "Bugs?  They aren't bugs! They're undocumented features!"  :)
 
14
!
 
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
 
18
!             in the game.
 
19
!
 
20
!             As an example, Zork has a "what is a grue" style of command.
 
21
!
 
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.
 
26
!
 
27
! Usage     - Include this file after parser.h
 
28
!
 
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.
 
32
!
 
33
!             Any object that is in scope may be queryed
 
34
!
 
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
 
38
!
 
39
!             As a final option, the action WhatIs may be used in an
 
40
!             objects 'before' code to print the whatis text.
 
41
!
 
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.
 
45
!
 
46
! In game   - A player can type text in this format :
 
47
!             ["what"|"who"]  ["is"|"am"|"are"] <object>
 
48
!
 
49
!             eg: "who am I"
 
50
!                 "what is a disintegrator"
 
51
!                 "what are bombs"
 
52
!                 "what is the big green door"
 
53
!
 
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'
 
56
!               property.
 
57
 
 
58
Attribute queryable;
 
59
property  whatisit;
 
60
 
 
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."; ];
 
65
 
 
66
[ WhoAmISub;
 
67
    print "You are ";
 
68
    if( ZRegion(player.short_name) == 2 or 3 )
 
69
    {
 
70
        PrintOrRun(player,short_name,1);
 
71
        rtrue;
 
72
    }
 
73
    "yourself.";
 
74
];
 
75
 
 
76
[ WhatIsSub;
 
77
    if( noun == player ) <<WhoAmI>>;
 
78
    if( noun hasnt queryable ) "Good question.";
 
79
    if( ZRegion(noun.whatisit) == 2 or 3 )
 
80
    {
 
81
        PrintOrRun(noun,whatisit);
 
82
        rtrue;
 
83
    }
 
84
    "Good question.";
 
85
];
 
86
 
 
87
[ QueryScope;
 
88
    if( scope_stage == 1 ) rfalse;
 
89
    if( scope_stage == 2 )
 
90
    {
 
91
        ScopeWithin( QueryObjs );
 
92
        rfalse;
 
93
    }
 
94
];
 
95
 
 
96
Object QueryObjs "Queryable objects";
 
97
 
 
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;