LanguageVerb function: 2-word commands?

I have used the LanguageVerb function a lot to deal with the “only understood as far as” error for unusual metaverbs, e.g. “about.”

But I’m confused by how to get 2-word commands to work.

Include (-
Replace LanguageVerb;
-) after "Definitions.i6t".

room 1 is a room.

Include (-
[ LanguageVerb i;
	switch (i) {
	  'i//','inv','inventory':
			   print "take inventory";
	  'l//':   print "look";
	  'x//':   print "examine";
	  'z//':   print "wait";
	  'avada kedavra//':    print "cast a killing curse (2 words)";
	  'avada':    print "cast a killing curse (1 word)";
	  'about':  print "see info about the game";
	  default: rfalse;
	}
	rtrue;
];
-) after "Language.i6t".

understand the command "avada kedavra" as something new.
understand "avada kedavra" as requesting the score. [ok, it does something else, but let's keep the example simple]

test ak with "avada kedavra x"

In the example above, I’d like to see “cast a killing curse (2 words)” but instead I see “cast a killing curse (2 words) kedavra.” This makes sense, since LanguageVerb is called from Parser.i6t on a word by word basis.

But is there an easy, sensible way to do this in inform 6? I suppose I could really hardcode things in Inform 7 with an "after reading the player’s command: (change regex “^avada kedavra” to “avadakedavra” and use avadakedavra as a command) but this looks like a hack.

I could also have a table that the “Rule for printing a parser error when the latest parser error is the only understood as far as error” reads through and then notes you used a 2 word command, but again, that feels like a real hack.

It’d be acceptable, but I can’t help feeling there’s something a lot better.

Thanks for any and all help!

PrintCommand has the job of printing the entire player command. It calls LanguageVerb on the first word (de-abbreviating it), and then prints the rest of the grammar line, inserting the parsed objects as needed.

Note that your line “‘avada kedavra//’: print …;” can’t work as written. ‘avada kedavra’ can never be a dict word in the player’s input, because the input routine treats spaces as a separator.

(Also, the ‘//’ is only needed for one-letter dict words. ‘x’ is a character value, ‘x//’ is a one-letter word, but ‘avada’ is unambiguous and doesn’t need the //.)

So it sounds like you want to add more logic to PrintCommand. I think you want to check action_to_be; if that’s a specific action value (the avada kedavra action), you print your string and skip the rest of PrintCommand.

Thanks, Zarf! I tried a few things at first, and while I haven’t gotten it nailed down, what you have is a good start. It feels right, and I think I’m being thick about the execution. I’ll post something if/when I figure what’s going on.

Also, I really did try just “avada kedavra” first but slapped on the “//” as a wild try that didn’t work.