Inform 7 - Situational "Understand"

Is there a syntax that allows the “understand” option to work in certain circumstances and differently in others?

For example:
“Make Sandwich” would try to construct a sandwich out of the materials.
“Make Bed” would try to clean (rub) the bed.

I wasn’t planning on making a “construct” verb- they’d never need to make a sandwich. But if they try to use “Make” in that context, I don’t want it to always default to “rub”.

I tried
Understand “make bed” as making the master’s bed. (this doesn’t work).
I tried “Understand make [any supporter]” as rubbing. (This gives me “the noun didn’t make sense in this context” if they try to make something else.).

Yeah, Inform can do this, and you’re almost right. There are a couple of approaches. If the circumstances are somewhat external to what the player is typing, you can append a “…when CONDITION” to an Understand statement – so like:

Understand "books" as the mess when the books are part of the mess.

For what you’re doing here, though, you want Inform to parse the command differently depending on exactly what the player types, so you’re right that you’d want to bake this into the grammar of the actions. The problem with your first try is that you can’t feed a specific action into an understand command in this way. From what you wrote, I can’t tell exactly what outcome you’re looking for in the second example – like, what you want to happen if the player types “MAKE WALL” or something, or whether you actually want MAKE SANDWICH to work. But here’s a quick example that hopefully would be easy to modify. Note that I stuck with your desire to have the actual bed-making use the existing clean/rub grammar and didn’t bother dealing with constructions like MAKE TOMATO (unlikely to come up) or MAKE TABLE (more likely) – you might want a check rule for the latter case since as written “make [supporter]” is redirecting to rub. Or you could just sub in “make [bed]” if this is a special case and nothing else will ever get made.

A supporter is either made or unmade.  A supporter is usually unmade.

The Test Chamber is a room.  The exit is north of the test chamber.

The bed is a supporter in the test chamber.  The description of the bed is "Your bed is [if the bed is unmade]messily unmade[otherwise]neatly made[end if]."

The tomato is in the test chamber.  The bread is in the test chamber.  The egg salad is in the test chamber.

The sandwich is an object.  It is edible.

Sandwich-making is an action applying to nothing.  Understand "make sandwich" as sandwich-making.

Check sandwich-making:
	If the tomato is not in the location or the bread is not in the location or the egg salad is not in the location, say "You need something to make the sandwich out of." instead.
	
Carry out sandwich-making:
	Say "You whip together a nice egg salad sandwich.";
	Now the tomato is nowhere;
	Now the bread is nowhere;
	Now the egg salad is nowhere;
	Now the player carries the sandwich.
	
Understand "make [supporter]" as rubbing.

After rubbing the bed:
	If the bed is made, say "It's already nice and neat." instead;
	Say "You spend a moment straightening and tucking in the sheets, then give the pillows a little plump.";	
	Now the bed is made.
1 Like