[SOLVED] Capitalizing a customised name
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.
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.
[SOLVED] Capitalizing a customised name
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?
Is this possible?
Last edited by chesarty on Wed Aug 21, 2019 12:01 am, edited 1 time in total.
- 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
You can add .upper() at the end but I'm not really sure what your code is for your character name
Re: Capitalizing a customised 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"
- 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
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
Re: Capitalizing a customised name
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 dialogueIrinaLazareva wrote: ↑Sun Aug 18, 2019 4:28 amIn 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
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"
- 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
You need to change one line in the say screen only:chesarty wrote: ↑Sun Aug 18, 2019 4:39 amCode: 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"
Code: Select all
text who.upper() id "who"
Code: Select all
text who id "[player_name]"
Re: Capitalizing a customised name
That still changes both the name tag and the dialogue.You need to change one line in the say screen only:
instead ofCode: Select all
text who.upper() id "who"
Code: Select all
text who id "[player_name]"
- 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
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.
- 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
isn't it easier to capitalize the name once after the players input and before saving it?
note: untested code, but should work.
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()
Re: Capitalizing a customised name
Oh my goodness, thank you! This worked on the first try <3 You're my saviour.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?note: untested code, but should work.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()
Who is online
Users browsing this forum: alyoshaslab