Using the name of the PC in standard responses (Inform 7)

In my game, the player has a name, e.g. John. But when I run my game I get messages like:

Lounge
He could see a chair here.

'>sit on chair
That was not something he could sit down on.

But what I would like is:

Lounge
John could see a chair here.

'>sit on chair
That was not something John could sit down on.

So far I have the following code, which may or may not be relevant to what I need(?):

“test” by me

[WHEN PLAY BEGINS]
when playing begins:
Now the story viewpoint is third person singular;
Now the story tense is past tense.

Lounge is a room.
the chair is a supporter in lounge.

Yourself has some text called the player’s name. Understand the player’s name property as describing yourself. The player’s name is “John Jackson”.
Yourself has some text called the player’s name2. Understand the player’s name2 property as describing yourself. The player’s name2 is “John”.
Yourself has some text called the player’s name3. Understand the player’s name3 property as describing yourself. The player’s name3 is “Jackson”.

Any help is much appreciated :slightly_smiling_face:

The first thing I can think of is to go through all the responses that contain pronouns referring to the player and change them. This would be a lot of drudgery, but it might be worth a shot if you were going to change them anyway.

The second idea is just to change the text substitutions that refer to the player. (This is in §14.4 of the documentation.) You can just write new definitions for them:

Lab is a room. John Jackson is a man in Lab. The player is John Jackson. Understand "John" and "Jackson" as John Jackson.

When play begins:
	now the story viewpoint is third person singular;
	now the story tense is past tense.

To say We: say "John".
To say we: say "John". 
To say Us: say "John".
To say us: say "John".
To say Our: say "John's".
To say our: say "John's".

I didn’t change “ourselves” because it seemed like you would actually want the pronoun there.

This can be a bit stilted when the protagonist appears more than once in a message.

> stand on john
John was not something John could stand on.

Something you could try there, if you want to get fancy, is making the text substitution print “John” the first time, and revert to the pronoun other times. This is a little more involved, and as I suffer under a curse where I can’t mention something like this without attempting to code it up, I’ll try to code it up in a little bit.

Also, as you can see in my code, instead of making the player “yourself” you can give the player a name and also write Understand statements for the name, instead of using properties. (I wasn’t sure if the PC’s name could vary, in which case you would want to use properties.) Ordinarily when something has a name, you don’t need special Understand statements for the name, but when it’s the player you do (I think).

EDIT: OK, here’s that coded up:

Lab is a room. John Jackson is a man in Lab. The player is John Jackson. Understand "John" and "Jackson" as John Jackson.

When play begins:
	now the story viewpoint is third person singular;
	now the story tense is past tense.

Name printed is a truth state that varies.
After reading a command: now name printed is false. [don't want to hook this to "every turn" or "before" because we want to reset it even when no turn elapses, because we're printing a parser error.]

To say We: 
	if name printed is false:
		say "John";
		unless expanding text for comparison purposes:
			now name printed is true;
	otherwise:
		say "He".
To say we: 
	if name printed is false:
		say "John";
		unless expanding text for comparison purposes:
			now name printed is true;
	otherwise:
		say "he".
To say Us: 
	if name printed is false:
		say "John";
		unless expanding text for comparison purposes:
			now name printed is true;
	otherwise:
		say "Him". [...I don't see how this could possibly be part of a grammatical sentence?]
To say us:
	if name printed is false:
		say "John";
		unless expanding text for comparison purposes:
			now name printed is true;
	otherwise:
		say "him".
To say Our: 
	if name printed is false:
		say "John's";
		unless expanding text for comparison purposes:
			now name printed is true;
	otherwise:
		say "His".
To say our:	
	if name printed is false:
		say "John's";
		unless expanding text for comparison purposes:
			now name printed is true;
	otherwise:
		say "his".

The business about “expanding text for comparison purposes” happens because Inform sometimes silently calculates text substitutions (when figuring out what indefinite article to use, and when comparing text substitutions for each other), and when it’s doing that we don’t want it to reset the flag. I could not find that documented in the built-in documentation but zarf mentioned it here! [EDIT 2: jrb discusses it more here and mentions that it’s not in the documentation.]

One thing about this is that if multiple messages are generated then the pronoun will get used after the first message that uses the name, but I kind of like that:

>jump. stand on john. take john
John jumped on the spot.

He was not something he could stand on.

He was always self-possessed.

5 Likes

Thanks a lot! Looks like this is what I need. I will give it a closer look tomorrow.

I honestly thank everything soft and fluffy for your curse, Matt. I don’t rely on it, but wow I’ve learnt some handy stuff from you in the short time I’ve been here. Your method works well for my learning style - examples (even incomplete ones) show me the nature of a process and give me ideas about it.

Thanks for your work!

1 Like

Just a brief update: It works perfectly, so thanks!

1 Like

I also needed to solve this same problem. Thanks Matt!

2 Likes