Asking questions of the player before play begins

Howdy! I am building my first attempt at a game, and it is particularly important that there be a password - Not that I am afraid of people playing the game, but because it is a tradition that in my particular group of friends we always password protect our projects, games, web pages, etc. the same way. Since I’m pretty sure many of my friends have never dealt with a text game, I also want a way to turn on a noob mode.

I wanted to ask two questions before play begins:

“What is the password?”
and
“Are you a text game noob?”

I have two bits of code that start with “When play begins” and when I run the game, it skips the password question and goes straight to the noob question (which seems to work on it’s own.) So I’ve been lurking on the forums and reading the documentation, and this is the code I have so far:

[code]
When play begins:
now the command prompt is “Enter password >”.

After reading a command when the command prompt is “Enter password >”:
if the player’s command matches “password” or the player’s command matches “Password”:
move the player to the detective office;
otherwise:
say “Password denied.”;
move the player to the void.

When play begins:
say “Are you a text game noob? >”;
now novice mode is whether or not the player consents.[/code]

I am lost trying to figure out how to have the game wait for a command from the player before moving on to a different question.
This doesn’t work but is this anywhere closer to what I should be doing?

[code]When play begins:
say “Enter password >”;
now password state is whether or not the player’s command is true.

Definition: The password state is true if the player’s command matches “password” or the player’s command matches “Password”.

Password state is a truth state that varies.

When play begins:
If the password state is true:
move the player to the detective office;
Otherwise:
move the player to the void.

When play begins:
say “Are you a text game noob? >”;
now novice mode is whether or not the player consents.

Novice mode is a truth state that varies. Novice mode is true. [/code]

Probably not. Probably not at all.

Going with your first approach:

[code]When play begins:
now the command prompt is “Enter password >”.

After reading a command when the command prompt is “Enter password >”:
if the player’s command matches “password” or the player’s command matches “Password”:
move the player to the detective office;
otherwise:
say “Password denied.”;
move the player to the void.

When play begins:
say “Are you a text game noob? >”;
now novice mode is whether or not the player consents.[/code]

The issue is that the whole “reading a command” loop happens after the “when play begins” stage. So, even though your first When Play Begins rule runs before the “Are you a noob?” rule, it doesn’t actually have any visible effect until after that rule has run and the banner text has printed.

The way I would do this would be to put the “Are you a noob?” question inside the “After reading a command” rule to make sure it runs at the right time. Also, since we are going to be going through all this on the first turn, you probably want to suppress the banner text until after going through that rule, the way it’s done in the Bikini Atoll example.

So:

[code]Start room is a room. Detective Office is a room. “A detective office for [if novice mode is true]new[otherwise]experienced[end if] detectives.” The void is a room.

When play begins:
now the command prompt is “Enter password >”.

After reading a command when the command prompt is “Enter password >”:
if the player’s command matches “password” or the player’s command matches “Password”:
say “Are you a text game noob? >”;
now novice mode is whether or not the player consents;
now delaying banner text is false;
say “Here’s where we print anything else that goes above the banner.”;
say banner text;
move the player to the detective office; [moved this down here to delay the room description until after the banner text]
otherwise:
say “Password denied.”;
move the player to the void, without printing a room description;
now the command prompt is “>”; [better change it back!]
reject the player’s command. [so the game doesn’t try to parse the password]

Novice mode is a truth state that varies. Novice mode is initially true.

Delaying banner text is a truth state that varies. Delaying banner text is initially true.

For printing the banner text when delaying banner text is true: do nothing.
Instead of looking in Start room: do nothing.[/code]

yielding:

(Your second approach has a couple of problems that prevent it from compiling–for one thing, I don’t think you meant to write “player’s command is true”–but the big problem with the approach is that in order for “the player’s command” to be anything you want to test, you already have to have gone through the Reading a player’s command activity, and that won’t happen until after the When Play Begins stage, as above. Testing “the player consents” is very unusual in that whenever you test it the game prompts the player for an input–testing things involving “the player’s command” isn’t like that, you can’t do it unless the player has already entered a command.)

Here’s an alternate approach using scenes.

The authentication piece is adapted from the “Do you remember our name?” code in Counterfeit Monkey, and I’ve borrowed the banner delay from Matt’s code above.

The password is always "password".
Password guess is initially "".
Max password attempts is always 3.
Password attempts is initially 0.

Delaying banner is initially true.
Rule for printing the banner text when delaying banner is true: do nothing.

Authentication is a scene.
Authentication begins when play begins.
Authentication ends successfully when password guess is the password.
Authentication ends unsuccessfully when password guess is not the password and password attempts >= max password attempts.

When authentication begins:
	now the command prompt is "Enter password >".

Instead of looking during authentication:
	do nothing.
	
After reading a command during authentication:
	now password guess is "[the player's command]" in lower case;
	now password attempts is password attempts + 1;
	follow the scene changing rules;
	if authentication is happening, say "Password incorrect.";
	reject the player's command.
	
When authentication ends:
	now the command prompt is ">".
	
When authentication ends successfully:
	say "Password correct."
	
When authentication ends unsuccessfully:
	say "Password incorrect.[line break]Too many attempts.";
	now the player is in the Void.

Noob querying is a scene.
Noob querying begins when authentication ends successfully.
Noob querying ends when noob querying is happening.

Novice mode is initially false.

When noob querying begins:
	say "Are you a text game noob? >";
	now novice mode is whether or not the player consents;
	say "Novice mode [if novice mode is true]enabled[else]disabled[end if]."
	
When noob querying ends:
	now delaying banner is false;
	say "This is the initial text.[paragraph break]";
	say banner text;
	now the player is in the Detective Office.

Auth is a room. The printed name is "Authentication".

Void is a room. "You're floating, formless, in a void, because you didn't know the password."

Detective Office is a room. "This is your office. It's dingy, but comfortable."

You might also consider a text file. Inform checks for the presence of the file; if it exists and it contains the password, it runs; if the file does not exist or the password is wrong, it fails. You can combine the file with asking: it asks for the password; if the password is correct, it creates the file; if not, it quits out. This means the user only enters a password the first time the game runs, rather than every time.

Of course, this is far from secure; a person could open the text file and see what the password is, or send the Inform file along with the password file. But you didn’t specify it had to be bulletproof.