Matching player's command to spacebar

Fellow authors,

I’m writing a sci-fi IF, and one of the locations is a bar, aptly named the Space Bar, so I want to return a special message if the player inputs " ". I know I can’t be the first person to think of that, but it’s a good gag. Anyway, Inform doesn’t want me to do that. How can I check for matching the player’s command to " "? Is there a token for that? Here’s my code that doesn’t work:

After reading a command when the player is in Space Bar:
	if the player's command does not include " ":
		say "Yes, you're very smart.  Shut up.";
		reject the player's command;

I am using Inform 7 on Windows 8.0.

PS I’ve never had so much hatred for such a useful tool as Inform. It’s reasonably powerful, if you know how to use it - but even Google couldn’t turn up a simple list of tokens.

This is tricky because the parser does some processing before the “reading a command” activity. It parses the command into words; if there are no words, it generates the “I beg your pardon” message and starts over without reaching the “reading a command” activity.

This is usually what one wants, but for your question it’s a nuisance.

You have to put your message in the “I beg your pardon” parser error. But this requires a bit of I6 code, because the “player’s command” snippet has spaces trimmed off.

Rule for printing a parser error when the latest parser error is the I beg your pardon error:
	if the untrimmed command length is zero:
		say "I beg your pardon.";
	else:
		say "You hit space."

To decide what number is the untrimmed command length: (- UntrimmedCommandLength() -).

Include (-
[ UntrimmedCommandLength;
#ifdef TARGET_ZCODE;
	return (buffer->1);
#ifnot;
	return (buffer-->0);
#endif;
];
-).

I7’s syntax is built in phrases, not tokens. You may find the I7 syntax reference helpful – see the stickied I7 docs thread (https://intfiction.org/t/the-list-of-inform-7-documentation-as-of-19-dec-2011/3311/1).

Mmmm… it works! So, first of all, thanks.

The first bit of the code you suggested reads like the Inform 7 I know, but the second bit is alien in its syntax. What… is that? Is that an alteration to the code which Inform 7 is written in (wasn’t I7 written in I6?) It seems useful, so if I wanted to learn it, or look up related documentation, what should I call it?

Correct, that’s Inform 6. I7 is translated into I6, then compiled by the Inform 6 compiler into Z-code or Glulx.