Understanding a one-word command as answering

I’m trying to allow the player to type FOO as a synonym for SAY FOO (which from my understanding Inform maps to ANSWER FOO TO (someone). I think I’ve got the implicit “someone” part figured out by using a “Does the player mean” rule, but for the life of my I can’t get the FOO -> SAY FOO piece working.

From looking over the documentation, it seems as though it should be something like:

Understand the command “foo” as “[answering it that foo]”.

But that doesn’t work, nor do all the permutations I’ve tried involving moving quotation marks and square brackets around. Would very much appreciate any guidance anyone has on this, thanks so much!

(I’m aware that I can just define a new command fnording, understand “foo” as fnording, and then do an “Instead of fnording, try answering it that foo” rule, but I am resolving to be less kludgy).

I don’t think you can actually do that directly. The syntax would be:

Understand the command "foo" as answering it that.

But this won’t be accepted because there’s no way to supply the two missing nouns.

What you can do instead is to define a new action and have the execution of that action redirect to another action:

Saying foo is an action applying to nothing.
Understand "foo" as saying foo.
Carry out saying foo: try answering yourself that "foo".

Note that you do have to specify a specific person that you’re addressing (or “yourself”) for this to work. If you want to invoke the usual parser machinery to try to figure that out for you, then you have to amend the command a little:

Saying foo to is an action applying to one thing.
Understand "foo to [someone]" as saying foo to.
Carry out saying foo to: try answering the noun that "foo".

This (by itself, without the previous snippet) will still accept foo by itself, since the Inform parser tries to be helpful and automatically substitutes a missing noun where there’s only one person it could be applied to.

1 Like

Thanks, this is really helpful – kind of a nice feeling, after weeks of banging my head against easy problems, to have been stuck on one that’s actually hard :slight_smile: The new action approaches make sense and should be easy to implement, just wasn’t sure if I was missing something important about how “understand” works.

It’s also possible to have an Understand line that is just Understand "[text]" as guessing, if you have a guessing action that applies to one topic. The Quiz Show example in the documentation does this.

This is pretty broad-brush, though; literally every command that doesn’t start with a verb (or direction) will be directed to this action, so it’ll kill a lot of error messages.


Yeah, I briefly considered trying something like that and then backed away in horror when I started realizing the potential implications…