[SOLVED] Capitalizing a customised name

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
chesarty
Regular
Posts: 116
Joined: Sat Aug 25, 2018 3:07 am
Completed: 0
Contact:

[SOLVED] Capitalizing a customised name

#1 Post by chesarty »

In my game, all character names are capitalized in the name box since it looks better with the font I'm using. I'd like to get the same result with the customizable name of the main character, so instead of the name being 'Main character' it's 'MAIN CHARACTER'.
Is this possible?
Last edited by chesarty on Wed Aug 21, 2019 12:01 am, edited 1 time in total.

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Capitalizing a customised name

#2 Post by namastaii »

You can add .upper() at the end but I'm not really sure what your code is for your character name

User avatar
chesarty
Regular
Posts: 116
Joined: Sat Aug 25, 2018 3:07 am
Completed: 0
Contact:

Re: Capitalizing a customised name

#3 Post by chesarty »

namastaii wrote: Sun Aug 18, 2019 3:32 am You can add .upper() at the end but I'm not really sure what your code is for your character name
Here's my character code:

Code: Select all

define you = Character ("[player_name]", color="#ffffff")

$ player_name = renpy.input("Enter your name!")

    $ player_name = player_name.strip()
# The .strip() instruction removes any extra spaces the player 
# may have typed by accident.

#  If the player can't be bothered to choose a name, then we
#  choose a suitable one for them:
    if player_name == "":
        $ player_name="MC"
Pretty simple :D I'm not sure if the .upper() will work since I only want the customized name to be capitalized in the namebox, not within the dialogue the characters speak? :o

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: Capitalizing a customised name

#4 Post by IrinaLazareva »

chesarty wrote: Sun Aug 18, 2019 4:04 am Pretty simple :D I'm not sure if the .upper() will work since I only want the customized name to be capitalized in the namebox, not within the dialogue the characters speak? :o
In that case .upper() method can only be applied to the say() screen (screens.rpy file):

Code: Select all

screen say(who, what):

    ## elements of the say() screen

        if who is not None:
            window:
                id "namebox"
                style "namebox"
                text who.upper() id "who"           <<<< this line 
                
    ## another elements of the say() screen                
                

User avatar
chesarty
Regular
Posts: 116
Joined: Sat Aug 25, 2018 3:07 am
Completed: 0
Contact:

Re: Capitalizing a customised name

#5 Post by chesarty »

IrinaLazareva wrote: Sun Aug 18, 2019 4:28 am
chesarty wrote: Sun Aug 18, 2019 4:04 am Pretty simple :D I'm not sure if the .upper() will work since I only want the customized name to be capitalized in the namebox, not within the dialogue the characters speak? :o
In that case .upper() method can only be applied to the say() screen (screens.rpy file):

Code: Select all

screen say(who, what):

    ## elements of the say() screen

        if who is not None:
            window:
                id "namebox"
                style "namebox"
                text who.upper() id "who"           <<<< this line 
                
    ## another elements of the say() screen                
                
Dunno if I'm doing it wrong (I'm still a total noob when it comes to modifying code, lol) but that still capitalizes the character's name both in the namebox and in the dialogue :(

Code: Select all

screen say(who, what):
    style_prefix "say"

    window:
        id "window"

        if who is not None:

            window:
                id "namebox"
                style "namebox"
                text who id "[player_name]"

        text what id "what"
  

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: Capitalizing a customised name

#6 Post by IrinaLazareva »

chesarty wrote: Sun Aug 18, 2019 4:39 am

Code: Select all

screen say(who, what):
    style_prefix "say"

    window:
        id "window"

        if who is not None:

            window:
                id "namebox"
                style "namebox"
                text who id "[player_name]"

        text what id "what"
  
You need to change one line in the say screen only:

Code: Select all

text who.upper() id "who"
instead of

Code: Select all

text who id "[player_name]"

User avatar
chesarty
Regular
Posts: 116
Joined: Sat Aug 25, 2018 3:07 am
Completed: 0
Contact:

Re: Capitalizing a customised name

#7 Post by chesarty »

You need to change one line in the say screen only:

Code: Select all

text who.upper() id "who"
instead of

Code: Select all

text who id "[player_name]"
That still changes both the name tag and the dialogue.

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Capitalizing a customised name

#8 Post by namastaii »

Well it shouldn't..considering the dialogue has nothing to do with that line. When you reference the variable in a dialogue script, it should show up normal.

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Capitalizing a customised name

#9 Post by Kia »

isn't it easier to capitalize the name once after the players input and before saving it?

Code: Select all

define you = Character ("MC", color="#ffffff")

    $ player_name = renpy.input("Enter your name!")
    if player_name:
        $ player_name = player_name.strip()
        $ you.name = player_name.capitalize() 
note: untested code, but should work.

User avatar
chesarty
Regular
Posts: 116
Joined: Sat Aug 25, 2018 3:07 am
Completed: 0
Contact:

Re: Capitalizing a customised name

#10 Post by chesarty »

Kia wrote: Sun Aug 18, 2019 9:55 am isn't it easier to capitalize the name once after the players input and before saving it?

Code: Select all

define you = Character ("MC", color="#ffffff")

    $ player_name = renpy.input("Enter your name!")
    if player_name:
        $ player_name = player_name.strip()
        $ you.name = player_name.capitalize() 
note: untested code, but should work.
Oh my goodness, thank you! This worked on the first try <3 You're my saviour.

Post Reply

Who is online

Users browsing this forum: alyoshaslab