Adding a new verb to Inform 6

I’m trying to define a custom verb ‘use’ which will be used like ‘use X on Y’ where X and Y are any two nouns in scope of the current room. Here’s what I have so far:

[ UseSub; "There's no obvious way to use ", (address)noun, " on ", (address)second, "."; ];
Include "Grammar";
Verb "use" * noun 'on' noun -> Use;
...
Object -> FritzwigInbox "Fritzwig's inbox"
       with name 'box' 'inbox' 'Fritwig inbox' 'Fritzwig^s inbox' 'mail' 'mailbox',
            description ...,
            before [; 
                      ...
                      Use: 
                        print "You have used the ", noun;
                        if(noun=='Fritzwig') {
                           print "used inbox on fritz, stringily";
                           rtrue;
                        }
                        if(noun==Fritzwig) {
                           print "used inbox on fritz, symbolically";
                           rtrue;
                        }
                   ],
       ...

the default handling prints out garbage for noun and second, even if the verb was used as expected e.g. use hammer on nail. When I ‘use inbox on fritzwig’, I see a non-zero address for noun, but neither condition is matched so I’m guessing it’s set with an unrelated value.

Why aren’t noun and/or second getting set with the relevant nouns in my verb definition above? Are there other variables that I should use to access the noun arguments of the use verb?

print (address) is used to print dictionary words; in this case, you probably want print (the), which prints an object’s name preceded by a lowercase definite article.

print "There's…use ", (the)noun, " on ", (the)second, ".^";

In DM4:
(char) : print out the character which this is the ZSCII code for
(string) : print out this string
(address): print out the text of this dictionary word
(name) : Print the object’s short name alone
(the) : definite article
(The) : definite article capitalised
(a) : indefinite article
(A) : indefinite article capitalised

1 Like