1
! ---------------------------------------------------------------------------
2
! calyx_adjectives - This Inform library extension is heavily based on Andrew
3
! Clover's adname.h (which in turn is based on an example in the Inform
5
! Differences: * The adname property is additive.
6
! * The main Class is called Ad_Item instead of adnc.
7
! * Objects can be referred-to by an adname alone. The
8
! price to pay is that you have to take care of the
9
! actual difference yourself (see example below).
12
! Include this library before you define your objects.
13
! Written in 1997 by Miron Schmidt / Calyx. Placed in the
14
! Public Domain. Actually, I've only given it a new name at all because
15
! it is incompatible to Andrew's library.
18
! First, define an object like this:
19
! Ad_Item cigarette_lighter "cigarette lighter"
20
! with name 'lighter',
24
! Then, in ChooseObjects(), put in the following code:
25
! [ ChooseObjects obj code prio;
26
! if (code <2) { Your code }
29
! if (obj has adj_chosen) return prio;
32
! You can define your own ChooseObjects() priorities, but an object
33
! that was referred-to by its (noun) name should always have a higher
34
! priority than an object that was referred-to by an adname only.
36
! adj_chosen is an attribute that is set if the player referred to an
37
! object by adnames only (e.g. 'cigarette' in the example).
38
! Thus, a cigarette would be automatically chosen if it were in the
39
! same room as the lighter, but in other circumstances, 'cigarette'
40
! could also refer to the lighter.
41
! ---------------------------------------------------------------------------
45
Property additive adname;
46
Attribute adj_chosen; ! This is set if the object was
47
! chosen because of an adname.
48
! You may use this knowledge in a
49
! ChooseObjects routine.
53
adname 'the', ! If adname is 0, program crashes!
55
return AdnameParser(self); ! Calling another routine like this
56
! avoids excessive code duplication,
57
! and allows you to extend an
58
! object's parse_name routine whilst
59
! still calling the adname parser.
63
[ AdnameParser adobj w n i j a b succ fail;
64
if (parser_action==##TheSame) {
66
n=(parser_one.#adname)/2;
68
j=(parser_two.#adname)/2;
75
if (fail==1) return -2;
83
if (fail==1) return -2;
85
return 0; ! This bit adapted from the parser - check all words in
86
! adname of parser_one to see if they occur in adname of
87
! parser_two, then vice-versa. If either case is false, we
88
! say the objects are not the same (the player may type a
89
! word that distiguishes then); if both are true, we give the
90
! parser a crack at seeing if they're different (by looking
91
! at the name property).
100
for (i=0:i<(adobj.#adname)/2:i++) {
101
if (w==adobj.&adname-->i) {
104
give adobj adj_chosen;
107
for (i=0:i<(adobj.#name)/2:i++) {
108
if (w==adobj.&name-->i) {
111
give adobj ~adj_chosen;
116
if (succ==1) return n-1;
118
! This is the bit of code executed normally (when the parser
119
! isn't trying to resolve identical objects). We just check
120
! that every word typed is in the adname or name property,
121
! and say that the phrase matches the object if any words are