Naming and understanding the protagonist [I7]

So, I’m trying to write up a bit where the player gets to define his/her name. It should be pretty standard, something like

Now the name of the player is "[the player's command]"

which works fine if all I’m doing is printing the player’s name (Say ‘"Hello, [name of the player]!’ bellows Harold.":wink:

But here’s the problem: The player-character changes during the game, so I need Inform recognize the original player’s new name.

It’s 5 am and I may not be explaining that clearly, so here’s an example:

George is a person. The player is George. Harold is a person. When play begins: Now the player is Harold.

If we type “x George,” Inform doesn’t realize we mean George because the character is privately-named. We can fix that by adding

Understand "George" as George

But what if the player changes George’s name to Captain during the game? We can’t just add

Understand "Captain" as George

Because we don’t know what the player is going to name George.

Is there any way around this? Can “Understand [a text that varies]” as a player?" Can we say that “Now the player is called “Captain”?”

I appreciate any input. Even if it’s just telling me to go to sleep. Especially if it’s just telling me to go to sleep.

That sounds like a thing that might be in the recipe book. Look at the Rumplestiltskin example which may not be exactly what you’re looking for, but could set you in the right direction.

Also remember “the player” and “yourself” trickily do not always mean the same thing. I think ‘yourself’ always refers to whom the player inhabits, but “the player” is a person (in the I7 sense) that can be switched out of.

It’s the other way around.

Seems like understanding by properties is the way to go here. (See writing with Inform §17.15.) If you’re using the printed name property (see example 19, “Laura”) to print the player’s name… which is kind of a natural thing to do… you can just piggyback on that:

[code]The Kitchen is a room.

George is a person in Kitchen. The player is George.
Harold is a person in Kitchen.

Understand the printed name property as describing a person.

Renaming is an action applying to one visible thing and one topic. Understand “rename [someone] [text]” as renaming.

Instead of renaming:
say “OK, [the noun] is called ‘[topic understood]’ now.”;
now the printed name of the noun is the topic understood.

After jumping when the player is George:
say “The impact dislodges your soul into the body of [Harold].”;
now the player is Harold.

Test me with “x me/x george/x harold/rename me Captain/x me/x george/jump/l/x captain”.[/code]

If you want to use something else to change the name of the player, just make it a property of that thing (or of people in general, if there can be more than one). One thing to watch out for is that when you understand with a text property like this, the player will have to use the whole text to succeed in referring–if they name themselves “Jennifer Jones” then they’ll have to say “x jennifer jones” rather than “x jennifer.” It’s not like when the person is named Jennifer Jones in the source code, and either “Jennifer” or “Jones” will work.

Good grief, that works. I could have sworn I tried that - Thanks! That’s immensely helpful.