Page 1 of 1

How can I customize a changeable name? [Solved]

Posted: Sun Nov 03, 2013 9:29 am
by Flowers from Nowhere
If I just assign a character a name I can change the color that the name appears in, add prefixes and suffixes, etc. just by defining the character that way:

Code: Select all

define unknown = Character('???', color="#c8ffc8", what_prefix="\"", what_suffix="\"")
With this code in place anything that unknown says will be in quotations and the name "???" will appear in the name box in the given color.

But what if I want to let the player rename the character? The way I know to do that is set a variable:

Code: Select all

$ person = renpy.input("My name is...", "Some Bloke")
Which will allow me to use person as a character but I don't know how to customize the color of the name (in this case the default name "Some Bloke") or add prefixes and suffixes.

Is there a way to do this?

Re: How can I customize a changeable name?

Posted: Sun Nov 03, 2013 10:28 am
by Megaman Z
Set the "name" of the character to the name of the variable (as a string) and specify dynamic=True on the same character. Alternatively, use DynamicCharacter for this, setting the "name" as the name of the variable. DynamicCharacter(name, [...]) is equivalent to Character(name, dynamic=True, [...])

In context, you're probably looking for something along the following lines:

Code: Select all

# Variable we're storing the name in
init:
    $ person = "???"

# Character who will be referred to as whatever person (see above) is at the time
define unknown = DynamicCharacter("person", color="#c8ffc8", what_prefix="\"", what_suffix="\"")
With that, at some point in the actual script (after label start or wherever), set person to be the result of renpy.input() as before and the name will change.

Re: How can I customize a changeable name? [Solved]

Posted: Sun Nov 03, 2013 2:38 pm
by Flowers from Nowhere
That works perfectly, thank you!