Understand "verb [thing] and [thing]" as one command

I have a command that takes two things, and I want to allow the player to word them as both “thing with thing” and “thing and thing”, but Inform parses the latter as trying to use the action twice with one noun each. Is there a way to do this?

(The context, if anyone is curious, is mixing: “mix vinegar with baking soda” and “mix vinegar and baking soda” both should be understood.)

1 Like

A noun phrase such as “vinegar and baking soda” will be interpreted as a multiple object list. This is a low-level feature of the parser that is difficult to change.

You may want to set up a separate action with a grammar line such as “mix [things]” to catch those cases, and then intercept and redirect the action when a multiple object list has been created.

See WWI 17.4 Standard tokens of grammar and WWI 17.20 Multiple action processing as well as RB 6.15 Actions on Multiple Objects for more.

EDIT: See also a previous thread on this issue at Equating "verb x with y" and "verb x and y"?.

5 Likes

Oh thanks, that thread didn’t come up when I was searching.

Here’s a quick implementation of the kind of thing I was talking about. I wrote it in 6M62, and it’s not fully tested.

Simple Recipe
"Simple Recipe"

Kitchen is a room.

Mixing it with is an action applying to two things. Understand "mix [something] with [something]" as mixing it with. The mixing it with action has a thing called mix result.

Check mixing it with:
	repeat through the Table of Mixed Results:
		if (first ingredient entry is the noun and second ingredient entry is the second noun) or (first ingredient entry is second noun and second ingredient entry is noun):
			make no decision;
	say "You don't think that's a good idea." instead.

Carry out mixing it with:
	repeat through the Table of Mixed Results:
		if (first ingredient entry is the noun and second ingredient entry is the second noun) or (first ingredient entry is second noun and second ingredient entry is noun):
			now mix result is result entry;
			move mix result to the holder of the noun; [hmmm, doesn't play well with alphabetical sorting]
			remove noun from play;
			remove second noun from play.

Report mixing it with:
	say "You mix together [the noun] and [the second noun], resulting in [a mix result]."

Mixing together is an action applying to one thing. Understand "mix [things]" as mixing together. [for handing "and" groups] The mixing together action has a list of things called mixing list.

First before mixing together (this is the transfer multiple object list to mixing list rule):
	now mixing list is the multiple object list;
	let L be a list of things; [throwaway list]
	add entry one of mixing list to L;
	alter the multiple object list to L. [prevent additional action processing cycles]

The announce items from multiple object lists rule does nothing when mixing together. [suppress for this action -- works in 10.1.2?]

Check mixing together when the number of entries in mixing list is one:
	say "You can't mix just one thing." instead.

Check mixing together when the number of entries in mixing list is at least three:
	say "Try just two things at a time." instead.

Carry out mixing together:
	try mixing entry one of mixing list with entry two of mixing list.

A counter is in Kitchen.

An egg, some flour, some vinegar and some baking soda are on the counter.

There are a grainy egg mess, a foamy mess, a denatured egg mess, some eggy flour sludge, some sour flour sludge, some eggy sour flour sludge, some self-rising flour, some unleavened dough and some unleavened sourdough. [all initially off-stage]

Table of Mixed Results [for convenience, ensure first ingredient is first alphabetically]
first ingredient (thing)	second ingredient (thing)	result (thing)
baking soda	egg	grainy egg mess
baking soda	eggy flour sludge	unleavened dough
baking soda	flour	self-rising flour
baking soda	vinegar	foamy mess
egg	flour	eggy flour sludge
egg	self-rising flour	unleavened dough
egg	vinegar	denatured egg mess
eggy flour sludge	vinegar	eggy sour flour sludge
flour	vinegar	sour flour sludge
unleavened dough	vinegar	unleavened sourdough

I’m a little surprised that there is no very similar example in the Recipe Book.

3 Likes

Thank you very much for writing all that! I used a quicker solution of just replacing “and” with “with” in the command if it starts with “mix” (with “\b” so it shouldn’t have many false positives) :sweat_smile:

Edit: perhaps your code could be generalized to an extension? Just mark a command somehow, and it’d do it automatically.

Unfortunately, Inform doesn’t have an equivalent to Python’s “decorators”, which is what you’d need for that. Having sample code to extend is probably the best we can do on that front.

Not even with an action kind?

That’s very neat.

And I see what you did there :laughing:

I’ve added this it to my personal Recipe Book.

1 Like

I can’t believe it flew over my head lol