names and genders at game start?

So I’ve been fighting with this for a few days now. I’ve been trying to figure out how to modify the examples in the Recipe Book section 5.2 to let me do both of these things, but it just isn’t working right. I don’t actually get any errors, but it isn’t working right in the game test.

My source

Getting Started is a room. Getting Started is private.

Gender is a kind of value. The genders are masculine, feminine, and nihil. Understand “male” or “man” or “M” as masculine. Understand “female” or “woman” or “F” as feminine.

A person has a gender. The gender of the player is nihil.

The player’s forename is an indexed text that varies. The player’s full name is an indexed text that varies.

When play begins:
now the command prompt is “Are you a man, or woman? >”.

After reading a command when the gender of the player is nihil:
if the player’s command includes “[gender]”:
now the gender of the player is the gender understood;
if the gender of the player is nihil:
say “This story requires a selection of male or female. [run paragraph on]”;
reject the player’s command;
if the gender of the player is masculine, now the player is male;
if the gender of the player is feminine, now the player is female;
now the command prompt is “What is your name?”;

To decide whether collecting names:
if the command prompt is "What is your name? > ", yes;
no.
After reading a command when collecting names:
if the number of words in the player’s command is greater than 5:
say “[paragraph break]Who are you, a member of the British royal family? No one has that many names. Let’s try this again.”;
reject the player’s command;
now the player’s full name is the player’s command;
now the player’s forename is word number 1 in the player’s command;
now the command prompt is “>”;
move the player to The Chamber;
say “[line break] You wake up cold and disoriented…”;
reject the player’s command.

The game test gives me this.

Getting Started

Are you a man, or woman? >man
That’s not a verb I recognise.

What is your name?john smith
That’s not a verb I recognise.

What is your name?

Does anyone have any idea what I’m doing wrong?

You’re almost there.

You need to end the rules with the phrase ‘reject the player’s command’, or Inform will go on to process the gender and the name as if they were ordinary commands (and complain it doesn’t understand them).

Also, the command prompt should be changed to "What is your name? > " rather than to “What is your name?” or the decide phrase won’t recognize it.

Could someone help me figure out where I’m missing the “reject the player’s command;” text? I thought got the spot it was missing, but it doesn’t seem to have made a difference.

[code]Getting Started is a room. Getting Started is private.

Gender is a kind of value. The genders are masculine, feminine, and nihil. Understand “male” or “man” or “M” as masculine. Understand “female” or “woman” or “F” as feminine.

A person has a gender. The gender of the player is nihil.

The player’s forename is an indexed text that varies. The player’s full name is an indexed text that varies.

When play begins:
now the command prompt is “Are you a man, or woman? >”.

After reading a command when the gender of the player is nihil:
if the player’s command includes “[gender]”:
now the gender of the player is the gender understood;
if the gender of the player is nihil:
say “This story requires a selection of male or female. [run paragraph on]”;
reject the player’s command;
if the gender of the player is masculine, now the player is male;
if the gender of the player is feminine, now the player is female;
now the command prompt is “What is your name?>”;

To decide whether collecting names:
if the command prompt is "What is your name? > ", yes;
no.
After reading a command when collecting names:
if the number of words in the player’s command is greater than 5:
say “[paragraph break]Who are you, a member of the British royal family? No one has that many names. Let’s try this again.”;
reject the player’s command;
now the player’s full name is the player’s command;
now the player’s forename is word number 1 in the player’s command;
now the command prompt is “>”;
move the player to The Chamber;
reject the player’s command;
say “[banner text]”;
say “[line break] You wake up cold and disoriented…”;
reject the player’s command.[/code]

“reject the player’s command” literally means “don’t parse the player’s command into an action”. You should use it anywhere you want to prevent an action from being parsed, even if the input was perfectly valid.

You need to ‘reject the player’s command’ at the end of the first ‘after reading a command’ rule.
The command prompts still don’t match (“What is your name?>” vs. "What is your name? >).
And there is some logic affecting trouble with the indentation in the ‘after reading a command’ rules.

This, I think, is what you want (with changes in mere indentation marked by ‘[]’ and other changes by ‘[!]’):

After reading a command when the gender of the player is nihil:
	if the player's command includes "[gender]":
		now the gender of the player is the gender understood;
	if the gender of the player is nihil: []
		say "This story requires a selection of male or female."; [!]
		reject the player's command; []
	if the gender of the player is masculine, now the player is male; []
	if the gender of the player is feminine, now the player is female; []
	say conditional paragraph break; [!]
	now the command prompt is "What is your name? >"; [!]
	reject the player's command. [!]
		
To decide whether collecting names: 
	if the command prompt is "What is your name? >", yes; [!]
	no. 
	
After reading a command when collecting names:
	if the number of words in the player's command is greater than 5: 
		say "Who are you, a member of the British royal family? No one has that many names. Let's try this again."; 
		reject the player's command; 
	now the player's full name is the player's command; []
	now the player's forename is word number 1 in the player's command; []
	now the command prompt is ">"; []
	say conditional paragraph break; [!]
[	reject the player's command; ] [!]
[	move the player to The Chamber;] [!]
	say "[banner text]"; []
	move the player to The Chamber; [!]
	say "[line break] You wake up cold and disoriented..."; []
	reject the player's command. []

The noted program seems to be a merging of two examples from the documentation.
I had trouble with getting the documentation example to run and also had the same issue with the previous example.
It appears as if the Decide clause is always returning true, so one gets the names printed on startup, but not when one tries to examine the letter in a subsequent command.
Can anyone see why the Decide clause is not working as expected?

[code]Part 1 - Collecting Names

The player’s forename is a text that varies. The player’s full name is a text that varies.

When play begins:
now the command prompt is “What is your name? >”.

To decide whether collecting names:
if the command prompt is “What is your name? >”, yes;
no.

After reading a command when collecting names:
if the number of words in the player’s command is greater than 5:
say “[paragraph break]Who are you, a member of the British royal family? No one has that many names. Let’s try this again.”;
reject the player’s command;
now the player’s full name is “[the player’s command in title case]”;
now the player’s forename is word number 1 in the player’s full name;
now the command prompt is “>”;
say “Hi, [player’s forename]![paragraph break]”;
say “[banner text]”;
move the player to the location;
reject the player’s command.

Instead of looking when collecting names: do nothing.

Rule for printing the banner text when collecting names: do nothing.

Rule for constructing the status line when collecting names: do nothing.

Your Bedroom is a room. The printed name of Your Bedroom is “[player’s forename]'s Bedroom”.

The player carries a letter. The description of the letter is “Dear [player’s full name], [paragraph break]You have won the Norwegian Daily Lottery! …”.
[/code]

The problem is not with the decide phrase but with this line:

now the player's full name is "[the player's command in title case]";

The text substitution is re-evaluated every time the text is printed, always using the most recent command. The simplest fix is to change it to

now the player's full name is the player's command in title case;

Thanks Juhana;

I should have spotted this. Your fix works.
However; it appears that the following extract from example 415 in the documentation has an error in the statement in question:

[code]If we are compiling for the Z-machine, the player’s input will unfortunately be reduced to lower case before we can inspect it. If we would like by default to capitalize the first letter of each word of the name, we might substitute the following after reading a command rule:

After reading a command when collecting names:
if the number of words in the player’s command is greater than 5:
say “[paragraph break]Who are you, a member of the British royal family? No one has that many names. Let’s try this again.”;
reject the player’s command;
now the player’s full name is “[the player’s command in title case]”;
now the player’s forename is word number 1 in the player’s full name;
now the command prompt is “>”;
say “Hi, [player’s forename]![paragraph break]”;
say “[banner text]”;
move the player to the location;
reject the player’s command.[/code]

You’re right, it’s a bug in the example. I’ve reported it here: inform7.com/mantis/view.php?id=1400

Thanks for logging it, Juhana. I haven’t logged anything before, so I’m not sure about the “rules”.