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

« back to all changes in this revision

Viewing changes to tutor/house05.inf

  • 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
 
! ------------------------------------------------------------------------------
2
 
! Inform for New Writers
3
 
!
4
 
! The House - Version 5
5
 
!
6
 
! Last Modified: David Cornelson - 22-Jan-1998
7
 
!
8
 
! ------------------------------------------------------------------------------
9
 
 
10
 
Constant Story "The House";
11
 
 
12
 
Constant Headline
13
 
           "^Inform for New Writers^
14
 
             The House - Version 5^
15
 
             By New Writer (1998) - Last Compiled: 22-Jan-1998^";
16
 
 
17
 
Constant MAX_SCORE 100;
18
 
Serial "980122";
19
 
 
20
 
Release 2;
21
 
 
22
 
Include "Parser";
23
 
Include "VerbLib";
24
 
 
25
 
!-------------------------------------------------------------------------------
26
 
! Initialise
27
 
!
28
 
!-------------------------------------------------------------------------------
29
 
 
30
 
[ Initialise;
31
 
 
32
 
  location = Sidewalk;
33
 
 
34
 
];
35
 
 
36
 
[ PrintRank;
37
 
  print ", earning you the rank of ";
38
 
  if (score >= 100) "the greatest.";
39
 
  if (score >= 80) "above average.";
40
 
  if (score >= 60) "average.";
41
 
  if (score >= 40) "below average.";
42
 
  if (score >= 20) "the barely living.";
43
 
  "the living dead.";
44
 
];
45
 
 
46
 
! ----------------------------------------------------------------------------
47
 
! Locations
48
 
!
49
 
! In this section we will define our locations. These are "Objects" to Inform.
50
 
!
51
 
! ----------------------------------------------------------------------------
52
 
 
53
 
!
54
 
! VERSION 5 - Adding a container to your game, functions, verbs, and death.
55
 
!
56
 
! In many cases you will want an object to be able to contain other objects.
57
 
! This may be as simple as creating a 'backpack' that will contain your school
58
 
! papers, apple, and pencil sharpener. In a more complex definition, a container
59
 
! could be a chasm, a bottomless pit, refrigerator, or a television.
60
 
!
61
 
! We're going to create a simple container and a complex container.
62
 
!
63
 
! The simple container is probably very familiar to you. It's a mailbox amd it's
64
 
! right here in front of the house. It contains a letter that can be read as well.
65
 
!
66
 
 
67
 
Object Sidewalk "Sidewalk"
68
 
    with  description
69
 
          "You are standing on the sidewalk in front of a house to the west.",
70
 
    w_to  Front_Porch,
71
 
    has   light;
72
 
 
73
 
!
74
 
! Add the mailbox with open and closed descriptions.
75
 
!
76
 
Object -> Mailbox "mailbox"
77
 
    with    name "mailbox" "box",
78
 
    when_open   "There is an open mailbox here.",
79
 
    when_closed "There is a closed mailbox here.",
80
 
    has     static container openable;
81
 
 
82
 
!
83
 
! Add 'legible' attribute to distinguish something that can be 'read'.
84
 
! This is determined in the verb extension located in the grammar
85
 
! section at the end of this file.
86
 
!
87
 
Attribute legible;
88
 
 
89
 
!
90
 
! And here is the letter, which can be consulted, read, or torn up. If it's
91
 
! torn up, the letter is removed from the game, never to be seen again.
92
 
!
93
 
Object -> -> Letter "letter"
94
 
    with    name "letter" "paper",
95
 
            description
96
 
            "The letter is a simple page of notebook paper.",
97
 
    before  [; Consult,Read: "The letter contains a vague story about an evil couch,
98
 
                              but you can't make out anymore detail. Interesting
99
 
                              little tidbit though.";
100
 
               Tear: remove Letter;
101
 
                     "You rip the letter into tiny pieces that blow away in the wind.";
102
 
            ]
103
 
    has     legible;
104
 
 
105
 
Object Front_Porch "Front Porch"
106
 
    with  description
107
 
          "This is the front porch of the house. There are two doors
108
 
           leading inside. The door on the left leads west and the
109
 
           door on the right leads northwest.",
110
 
    e_to  Sidewalk,
111
 
    w_to  Left_Front_Door,
112
 
    in_to Left_Front_Door,
113
 
    nw_to Right_Front_Door,
114
 
    has   light;
115
 
 
116
 
Object -> Left_Front_Door "left front door"
117
 
    with    name "left" "front" "door",
118
 
            description
119
 
            "The left front door is made of brass.",
120
 
    when_open    "The left front door is open.",
121
 
    when_closed  "The left front door is closed.",
122
 
    door_to      Foyer,
123
 
    door_dir     w_to,
124
 
    has          static door openable;
125
 
 
126
 
Object Right_Front_Door "right front door"
127
 
    with    name "right" "front" "door",
128
 
            description
129
 
            "The right front door is made of wood.",
130
 
    when_open    "The right front door is open.",
131
 
    when_closed    "The right front door is closed.",
132
 
    door_to        [; if (location==Front_Porch) return Den; return Front_Porch; ],
133
 
    door_dir    [; if (location==Front_Porch) return nw_to; return se_to; ],
134
 
    found_in    Front_Porch Den,
135
 
    with_key    right_key,
136
 
    has            static door openable lockable locked;
137
 
 
138
 
Object Den "Den"
139
 
    with    description
140
 
            "You are in the den of the house. The living room is west of hear
141
 
             and the front porch is to the southeast.",
142
 
    se_to    Right_Front_Door,
143
 
    out_to   Right_Front_Door,
144
 
    w_to     Living_Room,
145
 
    has      light;
146
 
 
147
 
Object -> Rock "rock"
148
 
    with    name "rock",
149
 
            description
150
 
            "It's smooth and flat, perfect for skipping in a pond.",
151
 
    before    [;    Insert,PutOn,ThrowAt:
152
 
                        if (second==Evil_Couch) rfalse; ! Allow the rock to be eaten by couch
153
 
                        if (second==Pond) {
154
 
                            print "The rock skips across the water several times and sinks.
155
 
                                   Amazingly, after a few moments, the rock washes up at
156
 
                                   your feet. Wow, what an undertow!^";
157
 
                            move Rock to Backyard;
158
 
                            rtrue;
159
 
                            !
160
 
                            ! Replace rock so that player can try it again....
161
 
                            !
162
 
                         } else {
163
 
                             print "You can't throw the rock at ",(the) second, ".^";
164
 
                            rtrue;
165
 
                         }
166
 
            ];
167
 
 
168
 
Object Living_Room "Living Room"
169
 
    with    name "living" "room",
170
 
            description
171
 
            "This is the living room of the house. The den is to the east.",
172
 
    e_to    Den,
173
 
    has     light;
174
 
 
175
 
!
176
 
! And here is our evil couch. Anything put on or in the couch will be
177
 
! 'eaten', including you. In fact, by setting the 'deadflag' to 1,
178
 
! Inform is informed to 'end' the game because you have died.
179
 
!
180
 
! Notice we used the 'before' property and the 'Enter' and 'Receive'
181
 
! verbs to handle the action.
182
 
!
183
 
Object -> Evil_Couch "couch"
184
 
    with    name "couch" "sofa",
185
 
    when_open "There is a filthy, worn down couch here.",
186
 
    before  [;  Enter: deadflag=1;
187
 
                       "You are eaten by the couch.";
188
 
                Receive: remove noun;
189
 
                         "The couch eats ", (the) noun, " and belches.";
190
 
            ],
191
 
    has     static container open enterable;
192
 
 
193
 
Object Foyer "Foyer"
194
 
    with  description
195
 
          "You are standing in the foyer of the house. It seems as though
196
 
           you can go up a staircase, northwest, or back out the front
197
 
           door to the east.",
198
 
    out_to Front_Porch,
199
 
    e_to   Front_Porch,
200
 
    nw_to  Hallway,
201
 
    u_to   Upper_Hallway,
202
 
    has    light;
203
 
 
204
 
Object Hallway "Hallway"
205
 
    with   description
206
 
           "You are in the hallway on the first floor of the house. The
207
 
            foyer is southeast and the kitchen is west of here.",
208
 
    se_to  Foyer,
209
 
    w_to   Kitchen,
210
 
    has    light;
211
 
 
212
 
Object Kitchen "Kitchen"
213
 
    with   description
214
 
           "This is the kitchen of the house. A hallway can be seen to the
215
 
            east and an open doorway to the west leads out to the backyard.",
216
 
    e_to    Hallway,
217
 
    w_to    Backyard,
218
 
    out_to    Backyard,
219
 
    has        light;
220
 
 
221
 
Object Backyard "Backyard"
222
 
    with    name "yard",
223
 
            description
224
 
            "This is the backyard behind the house. There is a pond here.",
225
 
    e_to    Kitchen,
226
 
    in_to    Kitchen,
227
 
    has        light;
228
 
 
229
 
Object -> Pond "pond"
230
 
    with    name "pond" "water",
231
 
            description
232
 
            "It's a small pond, but wide enough to skip rocks.",
233
 
    has        static concealed container open;
234
 
 
235
 
Object Upper_Hallway "Upper Hallway"
236
 
    with   description
237
 
           "This is the second floor hallway. Rooms can be seen north and
238
 
            south and a staircase leads down.",
239
 
    n_to   North_Bedroom,
240
 
    s_to   South_Bedroom,
241
 
    d_to   Foyer,
242
 
    has    light;
243
 
 
244
 
Object North_Bedroom "North Bedroom"
245
 
    with   description
246
 
           "This is a bedroom on the north side of the house.",
247
 
    s_to   Upper_Hallway,
248
 
    has    light;
249
 
 
250
 
Object -> right_key "right key" with name "right" "key", article "the";
251
 
 
252
 
Object South_Bedroom "South Bedroom"
253
 
    with   description
254
 
           "This is a bedroom on the south side of the house.",
255
 
    n_to   Upper_Hallway,
256
 
    has    light;
257
 
 
258
 
! ----------------------------------------------------------------------------
259
 
!
260
 
! Functions
261
 
!
262
 
! ----------------------------------------------------------------------------
263
 
 
264
 
!
265
 
! Added function ReadSub so that the property 'before' can use it. The default,
266
 
! if there is no 'before read', is to examine the object.
267
 
!
268
 
[ ReadSub; <<Examine noun>>; ];
269
 
 
270
 
[ TearSub; "You can't tear that"; ];
271
 
 
272
 
! ----------------------------------------------------------------------------
273
 
! Grammar
274
 
!
275
 
! The grammar section includes the file "Grammar" and will later include
276
 
! extensions to the standard grammar library.
277
 
!
278
 
! ----------------------------------------------------------------------------
279
 
 
280
 
Include "Grammar";
281
 
 
282
 
!
283
 
! We also have to extend the read grammar to call ReadSub
284
 
! by default.
285
 
!
286
 
! We're using the 'Extend' statment because the word "read" is already defined
287
 
! in the grammar file included above. This adds our usage.
288
 
!
289
 
! The 'first' tag is used to indicate to Inform that this usage of the word
290
 
! "read" should be the first one checked. Without 'first', the "read" word
291
 
! will not work the way we want it to because the default usage will get
292
 
! called and will not handle our code properly.
293
 
!
294
 
! 'legible' is the attribute we created and by placing it here, we're telling
295
 
! Inform that this attribute must be present in the object to call this usage
296
 
! of the word "read".
297
 
!
298
 
Extend "read" first * legible                       -> Read;
299
 
 
300
 
!
301
 
! We've also added the ability to 'tear' an object. Notice
302
 
! we had to specify 'noun' and then direct the default to
303
 
! TearSub.
304
 
!
305
 
! By the way, the 'Sub' is added on automatically by Inform.
306
 
!
307
 
! The word 'noun' tells Inform that the word "tear" must be followed by a
308
 
! noun, otherwise Inform will reply, "What do you want to tear?".
309
 
!
310
 
Verb "tear" * noun                                    -> Tear;
311
 
!
312
 
! Q: I'm really confused! Inform uses the words "first", "second", and "noun".
313
 
!    Can you explain the difference again?
314
 
!
315
 
! A: Sure.
316
 
!
317
 
!    'first' is a flag used in the grammar statement "Extend" so that the
318
 
!    new usage is called before previously defined usages. Without this
319
 
!    flag, an older usage might get called and your code may not work.
320
 
!
321
 
!    'second' is a variable that Inform sets if there is a second noun in
322
 
!    the player's statement.
323
 
!
324
 
!    'noun' is a variable that Inform sets if there are any nouns in the
325
 
!    player's statement. It gets set to the first noun found.
326
 
!
327
 
!    > THROW ROCK AT POND
328
 
!
329
 
!              ^       ^
330
 
!            noun    second
331
 
!