This page is out of date

You've reached a page on the Ren'Py wiki. Due to massive spam, the wiki hasn't been updated in over 5 years, and much of the information here is very out of date. We've kept it because some of it is of historic interest, but all the information relevant to modern versions of Ren'Py has been moved elsewhere.

Some places to look are:

Please do not create new links to this page.


Who's that? Changing character names during the game

Quite often the first time a character appears in the game, the player won't know the name of the character, just that they're the "Maid" perhaps, or the "Stranger". Yet later, when the player has learned more about them, we want the game to refer to them differently.

Fortunately it's easy to do, using . We just use a placeholder (which Ren Py calls a "variable") and then change the meaning of this placeholder term when we want to.

define millie = DynamicCharacter("maid_name")
# we've chosen to call the variable "maid_name", but it doesn't exist yet.

label start:
    # Set "maid_name" to mean something early on in the game.
    # You don't have to use it right away.
    $ maid_name = "Maid"
    # ''now'' the variable "maid_name" exists - it's only created when you set it.

    millie "I hope you'll be comfortable here."
    millie "We always do our best to make our guests comfortable."
    millie "If you need anything, just ask for \"Millie\" - that's me."
    $ maid_name = "Millie"
    millie "The bell boy's just bringing your suitcases now."

The first three times that Millie speaks, she'll be identified as the "Maid", but after she's told the player her name, she'll be shown as "Millie".

For this simple example it would be just as easy to use two different Characters and switch between them after Millie has given her name. But imagine in a more complex game where Millie only gives her name if the player decides to tip her. By using DynamicCharacter, you don't have to think about whether the player chose to tip or not, the game will show "Millie" or "Maid" as appropriate.