# if the player's command matches ... (then)

I’ve already created a password puzzle that worked well using a similar format to the one below.
This new puzzle is based on a Japanese urban legend in which a little girls traps you in a bathroom and give you two seeming choices:

``` Door for Stall #1 is a door. Door for Stall #1 is southwest of the girls' bathroom and northeast of Stall #1. Door for Stall #1 is open. The cardboard tube is a thing. The description is "Maybe you should recycle it?". The cardboard tube is undescribed. The cardboard tube is in Stall #1. Understand "cyclinder" as cardboard tube. Understand "roll" as cardboard tube. After closing Door for Stall #1: now Door for Stall #1 is locked; say "The door closes with more force than you expected. Then you hear a 'click' sound and door seems to locked FROM THE OUTSIDE!! Of all the places to be trapped, this seems to be not only one of the most claustrophobic, but also the most unsanitary places. To add insult to injury, close the door reveals a toilet paper ring holding an empty roll. [PARAGRAPH BREAK] There is graffiti on the back of the door." Graffiti is an object. The graffiti is in Stall #1. The graffiti is undescribed. The description is "It reads, 'SAVE A TREE. SAVE YOUR LIFE!' Was this written by a young environmentalist?". After taking cardboard tube: say "You fidget with the toilet paper dispenser for a while until you loosen the the cardboard tube. It seems that the noise has alerted someone in the next stall because you then hear the voice that sounds like it belongs to a little girl. She asks: [line break]'Would you prefer the red toilet paper or the blue?'"; now the command prompt is "Your response? >"; After reading a command when the command prompt is "Your response? >": if the player's command matches "Blue" or the player's command matches "blue": end the story saying "You grow short of breath. You gasp as your body struggles for oxygen. Before you die, you hear the joyful laughter of a child.". After reading a command when the command prompt is "Your response? >": if the player's command matches "red" or the player's command matches "Red": end the story saying "A single red square of toilet paper falls from above. It lands on your arms and gives you a nasty, deep paper cut. Your bleed uncontrollably. Before you die, you hear the joyful laughter of a child". After reading a command when the command prompt is "Your response? >": if the player's command matches "No paper" or the player's command matches "No thanks" or the player's command matches "No" or the player's command matches "No paper please" or the player's command matches "I do not need any": say "You hear water flushing followed by a clicking sound"; increase the score by 5; say "[paragraph break] Your score has increased by 5 points!"; now Door for Stall #1 is unlocked; now Door for Stall #2 is unlocked; now the command prompt is ">".```

The trouble is that most of the commands I put in here do not respond the way I anticipated.
Sorry to keep flooding y’all with questions that may seem obvious. Trust me, I’ve poured over the rule books and forums looking for a fix, but I feel rather illiterate lately.

If you’re problem involves matching the player’s command to some text, try something like this.

``if the player's command exactly matches the text "[your text here]", case insensitively:``

See “19.5. Matching and exactly matching” in The Inform 7 Documentation for more details.

Hope this helps.

The phrase ‘end the story saying’ doesn’t actually end the game immediately; it sets a flag that the parser checks later on. Your problem is that since the parser doesn’t accept “blue” etc. as valid commands, a parser error intercepts and the current turn of the game never reaches the stage where the flag set by ‘end the story’ is checked.

You can force an end to the game by telling it to follow the shutdown rules:

[code]After reading a command when the command prompt is “Your response? >” (this is the blue death rule):
if the player’s command matches “blue”: [the parser doesn’t distinguish between upper and lower case letter in input, so you don’t need to write a special condition for “Blue”]
end the story saying “You grow short of breath. You gasp as your body struggles for oxygen. Before you die, you hear the joyful laughter of a child.”;

After reading a command when the command prompt is “Your response? >” (this is the red death rule):
if the player’s command matches “red”:
end the story saying “A single red square of toilet paper falls from above. It lands on your arms and gives you a nasty, deep paper cut. Your bleed uncontrollably. Before you die, you hear the joyful laughter of a child.”;
[/code]

I remember you mentioning this on a previous thread, so I tried this to confirm it.

[code]“Test”

After reading a command: end the story finally saying “It works!”.

The Testing Room is A Room.[/code]

However, when I did I got this result.

[code]Test
An Interactive Fiction
Release 1 / Serial number 130218 / Inform 7 build 6G60 (I6/v6.32 lib 6/12N) SD

Testing Room

l

``````*** It works! ***
``````

In that game you scored 0 out of a possible 0, in 1 turn.

Would you like to RESTART, RESTORE a saved game, QUIT or UNDO the last command?

[/code]

I think what you’re saying only holds when “reject the player’s command” is used and in this case it isn’t.

The deadflag is checked once by the I6 Main routine before each new turn; if the flag is set, the game runs the shutdown rulebook to end the story.

Now, if you enter a valid command, like LOOK, the current turn will eventually end, and if the deadflag is set by then, the story too will end. (I guess, as well, the parsing of the command is stopped short somewhere before the action rules usually run, if the deadflag is being set.)

But if you enter an invalid command, like BLUE or RED or something else that the game doesn’t understand, a parser error will intercept first, and the player will be asked to enter a new command the very same turn, and so Main() hasn’t yet got it’s chance of ending the story, even if deadflag is already set.