Just a small question. [Input player's name]

Hi, I’m working on a small game, and I was wondering if anyone knew of a way to have players input their name or if. It was even possible in this engine? I’m kind of still figuring out how it works, but I’d like to have players able to chose their name and maybe name an animal companion.

Take a look in the Recipe Book 5.2 - specifically the “Identity Theft” example.

inform7.com/learn/man/RB_5_2.html

I’ve tried that, but I can’t seem to get it to work right

Here, I’ve stripped down the example a little and added a bit to make the first letter of the name stay capitalized:

The street corner is a room. The description is "It's a street corner where you[if the player's name is not empty], [the player's name],[end if] are standing.";

The player's name is a text that varies.

When play begins:
	Now the command prompt is "What is your name?>"

After reading a command while the command prompt is "What is your name?>":
	now the player's name is word number 1 in the player's command in title case;
	say "Your name is [the player's name], is that right? [italic type](type yes or no)[roman type]";
	if the player consents: 
		now the command prompt is ">";
		stop the action;
	else:
		say "Sorry. Tell me again, so I get it right.";
		stop the action.

You get output like this:

street corner
It's a street corner where you are standing.

What is your name?>Jack
Your name is Jack, is that right? (type yes or no)no
Sorry. Tell me again, so I get it right.

What is your name?>Phillip
Your name is Phillip, is that right? (type yes or no)yes

>look
street corner
It's a street corner where you, Phillip, are standing.

Here’s an expanded example with naming a dog. It uses a text property assigned to the dog so that the dog can be referred to by name:


The street corner is a room. The description is "It's a street corner where you[if the player's name is not empty], [the player's name],[end if] are standing.";

The pet shop is east of the street corner. The description is "A cozy little shop. Smells like it's full of animals because it is."

The dog is an animal in the pet shop. The description is "[if the name of the dog is not empty]You look at [the name of the dog]. [end if]A ball of fluff. You're not sure which end is the front.";

The player's name is a text that varies.
The dog has some text called name.

Understand the name property as describing the dog.

When play begins:
	Now the command prompt is "What is your name?>"
	
After reading a command while the command prompt is "What is your name?>":
	now the player's name is word number 1 in the player's command in title case;
	say "Your name is [the player's name], is that right? [italic type](type yes or no)[roman type]";
	if the player consents: 
		now the command prompt is ">";
		stop the action;
	else:
		say "Sorry. Tell me again, so I get it right.";
		stop the action.

After examining the dog:
	if the name of the dog is empty:
		Now the command prompt is "What do you want to name the dog?>";
		
After reading a command while the command prompt is "What do you want to name the dog?>":
	now the name of the dog is word number 1 in the player's command in title case;
	say "You want to name the dog [the name of the dog], is that right? [italic type](type yes or no)[roman type]";
	if the player consents:
		now the command prompt is ">";
		stop the action;
	else:
		say "Sorry. Tell me again, so I get it right.";
		stop the action.

Sample output:

street corner
It's a street corner where you are standing.

What is your name?>Jack
Your name is Jack, is that right? (type yes or no)no
Sorry. Tell me again, so I get it right.

What is your name?>Phillip
Your name is Phillip, is that right? (type yes or no)yes

>e

pet shop
A cozy little shop. Smells like it's full of animals because it is.

You can see a dog here.

>look at dog
A ball of fluff. You're not sure which end is the front.

What do you want to name the dog?>Springer
You want to name the dog Springer, is that right? (type yes or no)no
Sorry. Tell me again, so I get it right.

What do you want to name the dog?>McStudmuffin
You want to name the dog Mcstudmuffin, is that right? (type yes or no)yes

>look at McStudmuffin
You look at Mcstudmuffin. A ball of fluff. You're not sure which end is the front.
2 Likes