[I7] Letting the player enter a name: Doesn't work PERIOD?

OK, I’m pretty close to giving up on letting the player choose their own name, but I want to make sure I personally am not doing anything wrong.

(inb4 “dude read da rulz” “use da search man” “wow first post and it’s asking for help that’s new /sarcasm”)

Well the problem seems to be in my code.

Here’s the name entering code (a slightly modified version of the “Identity Theft” example)

[code]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 3:
say “[paragraph break]The secretary looks at you tiredly and sighs. She tears the top page off the clipboard revealing a clean sheet. ‘You may enter up to three names: a first, a middle, and a last. If you don’t want to write them all down, that’s ok.’”;
reject the player’s command;
now the player’s full name is “[the player’s command in title case]”;
now the player’s first name is word number 1 in the player’s full name;
now the player’s last name is the last word in the player’s full name;
now the command prompt is “>”;
now name entered is true;
say “The secretary takes the clipboard, ‘Ok, mister… [player’s last name].’ You cringe at how terribly she mispronounces your name. 'You’ll want to go over into that room over there and just follow the staircase down until you come across the Test Room. Don’t go into any of the rooms besides the corridor. [paragraph break]Marigold nearly runs off without you. ‘Come ON, [player’s first name]!’”;
reject the player’s command. [/code]

The error I get when using this code:

[spoiler][code]
This is the report produced by Inform 7 (build 6G60) on its most recent run through:

In Part 3 - The Gameplay:

Problem. In the sentence ‘now the player’s full name is “[the player’s command in title case]”’ , I was expecting to read a condition, but instead found some text that I couldn’t understand - ‘player’s full name is “[the player’s command in title case]”’.

I was trying to match this phrase:

now (player’s full name is “[the player’s command in title case]” - a condition)

This was what I found out:

player’s full name is “[the player’s command in title case]” = something unrecognised


Problem. In the sentence ‘now the player’s first name is word number 1 in the player’s full name’ , I was expecting to read a condition, but instead found some text that I couldn’t understand - ‘player’s first name is word number 1 in the player’s full name’.

I was trying to match this phrase:

now (player’s first name is word number 1 in the player’s full name - a condition)

This was what I found out:

player’s first name is word number 1 in the player’s full name = something unrecognised


Problem. In the sentence ‘now the player’s last name is the last word in the player’s full name’ , I was expecting to read a condition, but instead found some text that I couldn’t understand - ‘player’s last name is the last word in the player’s full name’.

I was trying to match this phrase:

now (player’s last name is the last word in the player’s full name - a condition)

This was what I found out:

player’s last name is the last word in the player’s full name = something unrecognised


Problem. In the line ‘say “The secretary takes the clipboard, […] ‘Come ON, [player’s first name]!’”’ , I was expecting that ‘player’s last name’ would be something to ‘say’, but it didn’t look like any form of ‘say’ that I know. So I tried to read ‘player’s last name’ as a value of some kind (because it’s legal to say values), but couldn’t make sense of it that way either.

Sometimes this happens because punctuation has gone wrong - for instance, if you’ve omitted a semicolon or full stop at the end of the ‘say’ phrase.

I was trying to match one of these phrases:

  1. say "“The secretary takes the clipboard, 'Ok, mister… " - text”

  2. say “player’s last name - text”

  3. say “[player’s last name - number]”

  4. say “[player’s last name - unicode character]”

  5. say “[player’s last name - sayable value]”

  6. say “”.’ You cringe at how terribly she mispronounces your name. 'You’ll want to go over into that room over there and just follow the staircase down until you come across the Test Room. Don’t go into any of the rooms besides the corridor. " - text"

  7. say “[paragraph break]”

  8. say “paragraph break - text”

  9. say “[paragraph break - number]”

  10. say “[paragraph break - unicode character]”

  11. say “[paragraph break - sayable value]”

  12. say "“Marigold nearly runs off without you. 'Come ON, " - text”

  13. say “player’s first name - text”

  14. say “[player’s first name - number]”

  15. say “[player’s first name - unicode character]”

  16. say “[player’s first name - sayable value]”

  17. say “”!’" - text"

This was what I found out:

player’s last name = something unrecognised

paragraph break = something unrecognised

player’s first name = something unrecognised
[/code][/spoiler]

and for completeness’ sake, here’s my whole code:

[spoiler][code]“Royalty” by Daniel ‘Orangestar’ O’Day

Part 1 - The Options

Include Basic Screen Effects by Emily Short.

Use full-length room descriptions and no scoring. Use serial comma.

Part 2 - Before the Gameplay

When play begins:
say “‘Isn’t this exciting? It’s our 15th birthdays! We get to take The Test! I know you’ll ace it, though. 100%!’[paragraph break]You walk down the long, winding streets to the Test Center, with Marigold watching your every step. ‘Come on, Mary. You know non-royalty isn’t allowed to see the test. How can you be certain I’ll get a perfect score?’[paragraph break]Marigold playfully slaps your shoulder. ‘Oh pshaw,’ she replies. ‘I’m just trying to be optimistic! Don’t you ever wonder what it’s like to be a part of royalty? To live on the Floating Halo, high above the walls of the city? I’ve always wondered what they do up there all day… in their airships just flying around all day…’[paragraph break]‘Marigold, what if we fail the test though? Nobody’s ever come out of the Test Center-’[paragraph break]Marigold interrupts you with a sudden burst of vigor. ‘Oh we’re here! Let’s go in! Come on!’ She heads into the building before you can say anything.”;
pause the game.

Marigold following is a truth state that varies. Marigold following is false.
Name entered is a truth state that varies. Name entered is false.

Part 3 - The Gameplay
[how the source is usually read:]

[A room, with description]
Outside the Test Center is a room. “You are standing outside the Test Center where Marigold ran in without your permission earlier. The cool summer breeze blows through your hair as busy people bustle down the streets, children play in a nearby lawn, and The Floating Halo quietly hovers above the city.”

[things in the room]
The player is in the Test Center. Children, busy people, sunbathers, and The Floating Halo are scenery in the Test Center.

[and the description of those things.]
The description of the children is “The gleeful cheers of the children are not what you should be paying attention to right now.”
The description of the Floating Halo is “The Floating Halo looms ominously over you. In most areas of the city, what with the Halo covering most of it and the walls blocking the view of the horizon, there is nothing but darkness. Usually, the sun fits just right in the sky to show perfect light into the city, making high noon a prime time to watch sunbathers line the streets.”
The description of sunbathers is “Well, there aren’t any sunbathers now. It’s 4… or something like that. You don’t have a watch.”
The description of busy people is “You could try getting one of their attentions, but trust me, nobody will listen to you. They all have their own matters they’d like to take care of first before helping you with your seemingly minuscule problems.”
.

[Test Center’s Entrance]
The Test Center’s Entrance is north of Outside the Test Center. "You enter the Test Center into a small room. The walls are painted the blandest color of gray man’s eyes have ever seen. "

The table is a thing in the Test Center’s Entrance.
In the Test Center’s Entrance is a woman called the secretary. The initial appearance of the secretary is “A secretary stares at you behind the table.”

Carry out going to the Test Center’s Entrance for the first time:
say “Marigold notices you and waves at the nearby table. ‘Hey! come over here! You gotta sign in for The Test. Come on, slowpoke! I already signed and now I’m waiting on YOU.’”.

Marigold is a woman in the Test Center’s Entrance. “Marigold is running around the room, as usual.”.

Every turn:
If the location of Marigold is the location of the player:
say “Marigold says, ‘I’ll follow you!’”;
now marigold following is true;
if marigold following is false:
stop;
otherwise:
if the location of Marigold is not the location of the player:
let the way be the best route from the location of Marigold to the location of the player, using doors;
try Marigold going the way;
otherwise:
say “[one of]Marigold rushes about the room.[or]Marigold sits for a while, but can’t take it and stands back up.[or]Marigold smiles pleasantly at you.[or]Marigold begins to look bored.[or]Marigold begins to get antsy.[or]Marigold says ‘Can we go yet?’[as decreasingly likely outcomes]”.

[Instead of talking to the secretary:
say “Before you have the chance to speak, the secretary begins a heavily rehearsed ramble.[paragraph break]‘Welcome to the Test Center. This is where you will take The Test which will determine whether you will join the royalty in the Floating Halo. Please write your name down on this clipboard.’ The secretary produces a clipboard as she says so.[paragraph break]‘You may enter up to three names: a first, a middle, and a last. If you don’t want to write them all down, that’s ok.’”;
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 3:
say “[paragraph break]The secretary looks at you tiredly and sighs. She tears the top page off the clipboard revealing a clean sheet. ‘You may enter up to three names: a first, a middle, and a last. If you don’t want to write them all down, that’s ok.’”;
reject the player’s command;
now the player’s full name is “[the player’s command in title case]”;
now the player’s first name is word number 1 in the player’s full name;
now the player’s last name is the last word in the player’s full name;
now the command prompt is “>”;
now name entered is true;
say “The secretary takes the clipboard, ‘Ok, mister… [player’s last name].’ You cringe at how terribly she mispronounces your name. 'You’ll want to go over into that room over there and just follow the staircase down until you come across the Test Room. Don’t go into any of the rooms besides the corridor. [paragraph break]Marigold nearly runs off without you. ‘Come ON, [player’s first name]!’”;
reject the player’s command.

Before going east:
if name entered is false:
say “You’re not allowed to enter the Center until you’ve signed your name at the table. Try talking to the woman at the counter.”;
stop.

[Main Corridor]
Main Corridor is east of the Test Center’s Entrance.[/code][/spoiler]

Here’s the nuts part: Commenting out every single line I’ve used for entering names and replacing it with the default code for “Identity Theft” does not work either, giving me very similar errors! What’s going on here?

You need to initialize some of these variables:

The player's full name is indexed text that varies. The player's first name is indexed text that varies. The player's last name is indexed text that varies.

Inform sometimes infers what something’s supposed to be from context, but not this time; you have to tell it what those variables are. (I think this only happens when creating things, though, so that “The player wears a hat” will create a hat and make it wearable.)

Also, you use “last word in the player’s full name,” which isn’t recognized; you need something like this instead:

let N be the number of words in the player's full name; now the player's last name is word number N in the player's full name;

And there’s nothing that actually starts the entering name process, but you probably know that. (But on another note, you should definitely say which direction the next room is in the room description, or at least make the testing center inside from the starting room.)

I actually realized like most of this stuff immediately after posting this. I truly am an idiot.

At any rate the code works, and I used a more hackish method of choosing a player’s last name (if there are 3 words, if 2, etc…)

Same with possible exits. I’m gonna do regions last.

Hate to bump this with a new unrelated problem, but I fear making a whole new thread would be considered uncouth. I’m paranoid that way.

I’ve got a neat little menu for talking to Marigold in my code:

[code]Instead of talking to Marigold:
say “Marigold looks at you expectantly. ‘What’cha want[if name entered is true], [player’s first name][end if]?’[paragraph break]1) Tell Marigold to stay put.[paragraph break]2) Tell Marigold to go somewhere (This doesn’t work yet.)[paragraph break]3) Chat with Marigold.[paragraph break]4) Don’t say anything.”;
now the command prompt is “To Marigold >”.

To decide whether conversing with marigold:
if the command prompt is “To Marigold >”, yes;
no.

After reading a command when conversing with marigold:
if the player’s command matches “1”:
say “You tell Marigold to stay still. ‘Ok… but only if you’re going somewhere!’”;
now marigold following is false;
now marigold told to wait is true;
now the command prompt is “>”;
reject the player’s command;
otherwise if the player’s command matches “2”:
say “Marigold asks ‘Where?’”;
reject the player’s command;
otherwise if the player’s command matches “3”:
say “Can you just sign your name? I’m dying of boredom over here!”;
now the command prompt is “>”;
reject the player’s command;
otherwise:
say “Marigold frowns. ‘If you want to say something, say it next time!’”;
now the command prompt is “>”;
reject the player’s command.[/code]

Now if you read all that you’ve noticed #2 is awkwardly labeled and doesn’t do much. What I want to have is a function where the player types “2” and then a direction, such as “North” or “sw”.

The code I thought would work is

otherwise if the player's command matches "2 [a direction]": say "Marigold asks 'OK, I'll go [a direction]'"; try Marigold going a direction; now the command prompt is ">"; reject the player's command;
Which, it doesn’t, because apparently “[a direction]” is too ambiguous. But how am I supposed to get the player to say a direction and pass that on to the NPC to carry out going in that direction?

Much obliged.

I think this does what you want: the player can answer “2” to get a prompt from Marigold to enter a direction, or “2 north” etc. to send her right away. (Changes and additions to your code are marked with exclamation marks.)

After reading a command when conversing with marigold:
	if the player's command matches "1":
		say "You tell Marigold to stay still. 'Ok... but only if you're going somewhere!'";
		now marigold following is false;
		now marigold told to wait is true;
		now the command prompt is ">";
		reject the player's command;
	otherwise if the player's command includes "2": [!!!]
		now Marigold leaving is true; [flagging the choice] [!!!]
		if the player's command matches "2": [!!!]
			say "Marigold asks 'Where?'"; [!!!]
			reject the player's command; [!!!]
	otherwise if the player's command matches "3":
		say "Can you just sign your name? I'm dying of boredom over here!";
		now the command prompt is ">";
		reject the player's command;
	otherwise if the player's command matches "4": [!!!]
		say "Marigold frowns. 'If you want to say something, say it next time!'";
		now the command prompt is ">";
		reject the player's command.
		
Instead of going a direction (called away) when Marigold leaving is true: try asking Marigold to try going away; now Marigold leaving is false; now the command prompt is ">". [This converts the player going to Marigold going when the right flag is set.] [!!!]

Understand "2 [direction]" as a direction when Marigold leaving is true. [A synonym to N, S, E, W etc. when the right flag is set.] [!!!]

If you plan a lot of menu conversations and menu choices, it might in the end be easier to use one of the extensions for the purpose: Questions by Michael Callaghan or Simple Chat by Mark Tilford.

And, by the way, I don’t find it in the least uncouth to start a new thread for a new question. (Indeed, if someone was trying to remember where on Earth – or at least on the Forum – a certain coding problem was discussed, it might be easier to find it again if it has its own thread.)

You may also want to consider Reactable Quips or Quip-Based Conversation by Michael Martin.

Especially as finding a particular thread can be very tricky sometimes!