-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcutmsg.t
More file actions
313 lines (267 loc) · 10.2 KB
/
cutmsg.t
File metadata and controls
313 lines (267 loc) · 10.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
#charset "us-ascii"
#include <adv3.h>
#include <en_us.h>
/*
* custmsg.t
*. by Eric Eve (eric.eve@hmc.ox.ac.uk)
*. Version 1.1 - 28-Mar-08
*
* A small extension that makes it easier to customize or suppress certain
* library-generated pieces of descriptive text.
*
* (1) If postureReportable is set to nil on an ActorState, the
* library-generated postureDesc() (e.g. "Mavis is sitting on the wooden
* chair. ") is no longer incorporated into the description in response to
* an EXAMINE command.
*
* (2) Openable now has an openStatusReportable property (analogous to
* lockStatusReportable on Lockable) that makes it easy to suppress the
* "it's open" and "it's closed" messages that get tagged onto the end of
* the descriptions of Openable objects.
*
* (3) It's now easier to customize or suppress the "(providing light)"
* and "(lit)" messages that appear after the names of LightSources in
* inventory listings and the like; just override the providingLightMsg on
* the object in question. The mechanism can be extended to use other
* properties on other classes of objects using author-defined ThingStates.
*
* (4) The new Thing property specialContentsListedInExamine can be set
* to nil to suppress the listing of any contents that uses a specialDesc.
*/
/* Version 1.1 adds the openStatusReportable property to ContainerDoor */
/*
* The modifications to Actor and ActorState allow authors to opt in to
* including a postureDesc (e.g, "Mavis is sitting on the wooden chair. ")
* when a stateDesc is already provided, instead of having to opt out.
*/
modify Actor
replace examineStatus()
{
/*
* If I'm an NPC, show where I'm sitting/standing/etc. (If I'm
* the PC, we don't usually want to show this explicitly to avoid
* redundancy. The player is usually sufficiently aware of the
* PC's posture by virtue of being in control of the actor, and
* the information also tends to show up often enough in other
* places, such as on the status line and in the room
* description.)
*
* Also, we only show this if the curState's postureReportable
* property is true. This allows redundant posture descriptions
* to be suppressed if the current ActorState's stateDesc already
* mentions them.
*/
if (!isPlayerChar() && curState.postureReportable)
postureDesc;
/* show the status from our state object */
curState.stateDesc;
/* inherit the default handling to show our contents */
inherited();
}
;
modify ActorState
/*
* By default the actor's postureDesc() is displayed between its desc
* and the stateDesc on the current ActorState. If the stateDesc
* already mentions the actor's posture this may be redundant; changing
* postureReportable to nil suppresses the display of the
* postureDesc().
*/
postureReportable = true
;
//------------------------------------------------------------------------------
/*
* The following modification to ThingState is designed to make it easier to
* customize state-dependent messages such as '(providing light)' or
* '(being worn)'. The mechanism should be readily extensible to
* author-defined ThingStates.
*/
modify LightSource
/*
* The message that's appended to our name in inventory listings and the
* like when we're lit; the default in the English language library is
* '(providing light)'. To suppress the message altogether, set this
* property to nil. To replace it with another message, omit the
* parentheses, e.g. on a flashlight you might define:
*
* providingLightMsg = 'currently switched on'
*/
providingLightMsg = lightSourceStateOn.listName_
notProvidingLightMsg = lightSourceStateOff.listName_
;
modify Matchstick
/*
* The message that's appended to our name in inventory listings and the
* like when we're lit; the default in the English language library is
* '(lit)'. To suppress the message altogether, set this
* property to nil. To replace it with another message, omit the
* parentheses, e.g. :
*
* providingLightMsg = 'now ablaze'
*/
providingLightMsg = matchStateLit.listName_
notProvidingLightMsg = matchStateUnlit.listName_
;
modify Wearable
/*
* The messages that's appended to our name in listing when we're worn
* or unworn. By default this will be '(worn)' or nothing; but the
* wornMsg won't be used if we're appearing in a list of items
* introduced as being worn (e.g. "You are wearing...").
*/
wornMsg = wornState.listName_
unwornMsg = unwornState.listName_
;
modify ThingState
listName(lst)
{
/*
* if we have a msgProp and there's one item in our list, use the
* msgProp of that item to provide our state-dependent text.
*/
if(msgProp != nil && lst.length() == 1)
return (lst[1]).(msgProp);
/* Otherwise, use our listName_ (as in the standard library) */
return listName_;
}
/*
* The property on the object being described that will provide the
* text for any state-dependent extra description, such as 'providing
* light'. If this is defined, it should be set to a property pointer,
* e.g. &providingLightMsg. If it is left at nil ThingState will behave
* just as it does in the standard library.
*/
msgProp = nil
;
modify lightSourceStateOn
msgProp = &providingLightMsg
;
modify matchStateLit
msgProp = &providingLightMsg
;
modify wornState
msgProp = &wornMsg
;
/*
* Although the following three ThingStates don't display any state-related
* text in the standard library, equivalent modifications are added here
* to make it easy to add object-specific state information (e.g.
* 'currently switched off' on a flashlight) if so desired). This does not
* affect the standard library behaviour unless a game author chooses to
* override the notProvidingLightMsg_ property anywhere. These two
* ThingStates can also be given a listName_ property if a globally
* applicable message is required (e.g. 'unlit' for every unlit matchstick)
*/
modify lightSourceStateOff
msgProp = ¬ProvidingLightMsg
;
modify matchStateUnlit
msgProp = ¬ProvidingLightMsg
;
modify unwornState
msgProp = &unwornMsg
;
/*
* Note that the same coding pattern can be used if desired on custom
* ThingStates. E.g.
*
*. class MyCustomClass: Thing
*. allStates = [sillyState, sensibleState]
*. getState = sillyState
*. sillyMsg = sillyState.listName_
*. sensibleMsg = sensibleState.listName_
*. ;
*.
*. sillyState: ThingState 'silly'
*. stateTokens = ['silly']
*. msgProp = &sillyMsg
*. ;
*.
*. sensibleState: ThingState 'sensible'
*. stateTokens = ['sensible']
*. msgProp = &sensibleMsg
*. ;
*
* Note, however, that there is no need to define the msgProps if the
* ThingStates are being created for a single object, or if all the
* objects they will apply to are to use the same state-specific messages;
* in these cases ThingStates may be defined and used just as they are in
* the standard library. For example, if we never wanted to vary the
* 'silly' and 'sensible' messages on different objects, there would be no
* need (and not point) to define sillyMsg and sensibleMsg on
* MyCustomClass, and no need to define msgProp on sillySrate and
* sensibleState.
*
*/
//------------------------------------------------------------------------------
modify Openable
/*
* openStatusReportable works on analogy with lockStatusReportable on
* Lockable. It allows us to suppress the 'it's open' and 'it's closed'
* messages that follow the description of an Openable object (by
* setting this property to nil). By default this property is true,
* giving the standard library behaviour.
*
* It may also be useful to set this property to the value of an
* expression, e.g.:
*
* openStatusReportable = (isOpen)
*
* would result in the 'it's open' message being appended when we're
* open, but nothing being appended when we're closed.
*/
openStatusReportable = (canInherit() ? inherited() : true)
;
modify openableContentsLister
showListEmpty(pov, parent)
{
if(parent.openStatusReportable)
"\^<<parent.openStatus>>. ";
}
showListPrefixWide(itemCount, pov, parent)
{
if(parent.openStatusReportable)
"\^<<parent.openStatus>>, and";
else
"\^<<parent.theName>>";
" contain<<parent.verbEndingSEd>> ";
}
;
/*
* Make openStatusReportable work on ContainerDoor in the same way as it
* works on Openable.
*/
modify ContainerDoor
openStatusReportable = (canInherit() ? inherited() : true)
/*
* If we set OpenStatusReportable is set to nil, we may want to
* incorporate the open/closed state into our owm description. We
* borrow openDesc from Openable to facilitate this.
*/
openDesc = (delegated Openable)
replace examineStatus()
{
/* add our open status, if it is reportable */
if(openStatusReportable)
say(isOpen
? gLibMessages.currentlyOpen : gLibMessages.currentlyClosed);
/* add the base class behavior */
inherited();
}
;
//------------------------------------------------------------------------------
modify Thing
examineSpecialContents()
{
if(specialContentsListedInExamine)
inherited;
}
/*
* specialContentsListedInExamine works analogously to
* contentsListedInExamine, except that if it is nil it is the listing
* of this object's special contents (i.e. any contained object that
* uses a specialDesc or initSpecialDesc, including actors) that will
* be suppressed.
*/
specialContentsListedInExamine = true
;