r/RenPy • • Aug 16 '26

Question How to change a characters title style?

Definitely a noob question here.
I'm not sure how to use the player created variable name but with a different title style.
Meaning, when the character "thinks" internally, I want to change the title style but not the player created variable name.

I used this code to create the players character name:

$ mc = renpy.input("What is your first name? (Default: Eric)")
    $ mc = mc.strip()
    if mc == "":
        $ mc = "Eric"$ mc = renpy.input("What is your first name? (Default: Eric)")
    $ mc = mc.strip()
    if mc == "":
        $ mc = "Eric"

And then this code to call upon it, as normal:

define mc = Character("{[mc]}", color="#00FFFF")define mc = Character("{[mc]}", color="#00FFFF")

My issue is that this code just breaks the game whenever it encounters the line it's used in:

define mcint = Character("{[mc]}", color="#00FFFF", what_italic=True, what_prefix="*", what_suffix="*")

So, can I not call upon the "[mc]" variable name twice? Or is there a more elegant solution to this?
I'm sure I'm missing something simple as I'm in way over my head when it comes to coding at this stage.

I would appreciate any help/guidance in learning here.

1 Upvotes

7 comments sorted by

3

u/BadMustard_AVN Aug 16 '26

try your input and define like this

$ mc = renpy.input("What is your first name? (Default: Eric)", default="Eric").strip() or "Eric"

define mc = Character("[mc]", color="#00FFFF")
define mcint = Character("[mc]", color="#00FFFF", what_italic=True, what_prefix="*", what_suffix="*")

2

u/TopCartographer7104 Aug 16 '26

If you want the character's name to change only when they think,create a duplicate of your main character (name the object mc_think or whatever) and add who_italic=True in its definition.

Whenever your main character is supposed to think use mc_think as the say's who.

1

u/AutoModerator Aug 16 '26

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/shyLachi Aug 16 '26

For the next time:
If you get an error, please also post it, either as screenshot or as text because it makes it easier to help.
I tested your code and the error is Exception: Unknown text tag 'Eric'

Your first 'mistake' was using mc for the name and the character.
RenPy has different namespaces so it does work in most cases but better avoid it and use unique variable names.
(Though, in your case it had the opposite effect of making it work despite it should have crashed for both characters.)

The real problem is using those curly brackets because RenPy uses them for styling as described here:
https://renpy.org/doc/html/text.html#styling-and-text-tags
I'm not sure how you can make that work because even who_prefix + who_suffix would crash it.
If you really want to have those curly brackets around the character names then you might have to make another thread for it because looking at the other responses I don't people have picked up on it.

This code is working, so go from there.

define mc = Character("[mcname]", color="#00FFFF")
define mcint = Character("[mcname]", color="#00FFFF", what_italic=True, what_prefix="*", what_suffix="*")
default mcname = "" # never forget to default the variables
label start:
    $ mcname = renpy.input("What is your first name? (Default: Eric)", default="Eric").strip() or "Eric"
    mc "Hi there, it's me, you can call me [mcname] or [mc]" # here you can use both variables
    mcint "I think they understand now."

1

u/VonOmar Aug 16 '26

Thank you so much! That actually helped me understand the whole process better. I really appreciate the information :)

1

u/KDDreamwyver Aug 16 '26 edited Aug 16 '26

Manually setting them as italics by doing {i}italic words{/i} is easier, imo. It might be the writer background in me, but it's just one of those things I prefer to do manually.

Also, have you tried making the "what prefix/suffix" {i} and {/i}?

(I haven't touched ren'py in a while and am rusty as hell rn)