1
! ------------------------------------------------------------------------------
2
! Inform for New Writers
4
! The House - Version 5
6
! Last Modified: David Cornelson - 22-Jan-1998
8
! ------------------------------------------------------------------------------
10
Constant Story "The House";
13
"^Inform for New Writers^
14
The House - Version 5^
15
By New Writer (1998) - Last Compiled: 22-Jan-1998^";
17
Constant MAX_SCORE 100;
25
!-------------------------------------------------------------------------------
28
!-------------------------------------------------------------------------------
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.";
46
! ----------------------------------------------------------------------------
49
! In this section we will define our locations. These are "Objects" to Inform.
51
! ----------------------------------------------------------------------------
54
! VERSION 5 - Adding a container to your game, functions, verbs, and death.
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.
61
! We're going to create a simple container and a complex container.
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.
67
Object Sidewalk "Sidewalk"
69
"You are standing on the sidewalk in front of a house to the west.",
74
! Add the mailbox with open and closed descriptions.
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;
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.
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.
93
Object -> -> Letter "letter"
94
with name "letter" "paper",
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.";
101
"You rip the letter into tiny pieces that blow away in the wind.";
105
Object Front_Porch "Front Porch"
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.",
111
w_to Left_Front_Door,
112
in_to Left_Front_Door,
113
nw_to Right_Front_Door,
116
Object -> Left_Front_Door "left front door"
117
with name "left" "front" "door",
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.",
124
has static door openable;
126
Object Right_Front_Door "right front door"
127
with name "right" "front" "door",
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,
136
has static door openable lockable locked;
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,
147
Object -> Rock "rock"
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
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;
160
! Replace rock so that player can try it again....
163
print "You can't throw the rock at ",(the) second, ".^";
168
Object Living_Room "Living Room"
169
with name "living" "room",
171
"This is the living room of the house. The den is to the east.",
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.
180
! Notice we used the 'before' property and the 'Enter' and 'Receive'
181
! verbs to handle the action.
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.";
191
has static container open enterable;
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
204
Object Hallway "Hallway"
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.",
212
Object Kitchen "Kitchen"
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.",
221
Object Backyard "Backyard"
224
"This is the backyard behind the house. There is a pond here.",
229
Object -> Pond "pond"
230
with name "pond" "water",
232
"It's a small pond, but wide enough to skip rocks.",
233
has static concealed container open;
235
Object Upper_Hallway "Upper Hallway"
237
"This is the second floor hallway. Rooms can be seen north and
238
south and a staircase leads down.",
244
Object North_Bedroom "North Bedroom"
246
"This is a bedroom on the north side of the house.",
250
Object -> right_key "right key" with name "right" "key", article "the";
252
Object South_Bedroom "South Bedroom"
254
"This is a bedroom on the south side of the house.",
258
! ----------------------------------------------------------------------------
262
! ----------------------------------------------------------------------------
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.
268
[ ReadSub; <<Examine noun>>; ];
270
[ TearSub; "You can't tear that"; ];
272
! ----------------------------------------------------------------------------
275
! The grammar section includes the file "Grammar" and will later include
276
! extensions to the standard grammar library.
278
! ----------------------------------------------------------------------------
283
! We also have to extend the read grammar to call ReadSub
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.
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.
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".
298
Extend "read" first * legible -> Read;
301
! We've also added the ability to 'tear' an object. Notice
302
! we had to specify 'noun' and then direct the default to
305
! By the way, the 'Sub' is added on automatically by Inform.
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?".
310
Verb "tear" * noun -> Tear;
312
! Q: I'm really confused! Inform uses the words "first", "second", and "noun".
313
! Can you explain the difference again?
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.
321
! 'second' is a variable that Inform sets if there is a second noun in
322
! the player's statement.
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.
327
! > THROW ROCK AT POND