User input names, making character names not bold [RESOLVED]

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.
Message
Author
Variasaber
Newbie
Posts: 16
Joined: Sat Sep 24, 2011 11:35 pm
Completed: Ex Nihilo Unum (http://users.wpi.edu/~bmoriarty/imgd100 ... loUnum.rar)
Organization: 12000 Bombs
Location: Worcester Polytechnic Institute
Contact:

User input names, making character names not bold [RESOLVED]

#1 Post by Variasaber »

Hi guys. I registered here just now because there's something I need to ask about. Some other folks and I are working with Ren'Py for a project, and we've just recently started coding our game after going through the tutorials. Almost immediately we hit our first roadblock.

We're trying to set it up so that the game starts out by asking you what you want your character's name to be. We have it set up to receive text input from the player and store that as a variable, and then define a character whose name is set to that variable.

Here's the code for the user input:

Code: Select all

$ pov = renpy.input("Enter your name, or press Enter to continue.") or "John D."
And here's the code for the Character definition:

Code: Select all

define h = Character(pov, color="#58D3F7")
This returns an error. We then tried adding this a few lines before the user input code:

Code: Select all

define pov= 'John D.'
And that all checks out, but the Character's name then always comes out as John D. regardless of the user input.
The best I can figure is that Ren'Py is recognizing "define pov" and "$ pov" as different variables since one is a Python script and the other isn't, but the Character definition returns an error if you try to put a Python script in it (putting a $ before pov).

Does anyone know how to use user input to set a Character name?


Also, when displaying dialogue, Character names are shown in bold. This would be fine except that it makes the font we're using hard to read unless it's set unreasonably large. Does anyone know how to make the Character names display without bold?

Any help is greatly appreciated :mrgreen:
Last edited by Variasaber on Sun Sep 25, 2011 10:09 pm, edited 2 times in total.

Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: Setting Character names from user input, and something e

#2 Post by Soraminako »

I had a similar problem in the past, and found out how to do it from someone's kind help in another thread.
I don't remember which thread but here's the code:

Code: Select all

# The phrase in the brackets is the text that the game will display to prompt 
# the player to enter the name they've chosen.

    $ player_name = renpy.input("What is 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="John D."
 
# Now the other characters in the game can greet the player.
  
    e "Pleased to meet you, %(player_name)s!"
    #Edit: If you are using the new version of ren'py, use the following line instead of the one above, since that changed:
    #e "Pleased to meet you, [player_name]!"
And you define the character like this:

Code: Select all

    $ p = DynamicCharacter("player_name", color="#58D3F7")
Last edited by Soraminako on Sun Nov 13, 2011 12:16 am, edited 2 times in total.
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

manga_otaku
Veteran
Posts: 413
Joined: Fri May 20, 2011 1:27 pm
Completed: [KN] Saving Project: Blind? (Part One)
Contact:

Re: Setting Character names from user input, and something e

#3 Post by manga_otaku »

Instead of

Code: Select all

$ pov = renpy.input("Enter your name, or press Enter to continue.") or "John D."
try

Code: Select all

$ pov = renpy.input("Enter your name, or press Enter to continue.", "John D.")
When defining a character as a user inputs name, you put it in speech marks as well. For instance:

Code: Select all

define h = Character("pov", color="#58D3F7")
Well that's what I think anyway xD
Projects:
WIP|[KN] Day Of Reckoning|
Completed|[KN] Saving Project Blind: Part One|[KN] Saving Project Blind: Part Two|[KN] Saving Project Blind: Final Part|
Is available to help with proof-reading (Grammar freak...) Maybe voice-acting in the near future x]

Variasaber
Newbie
Posts: 16
Joined: Sat Sep 24, 2011 11:35 pm
Completed: Ex Nihilo Unum (http://users.wpi.edu/~bmoriarty/imgd100 ... loUnum.rar)
Organization: 12000 Bombs
Location: Worcester Polytechnic Institute
Contact:

Re: Setting Character names from user input, and something e

#4 Post by Variasaber »

Thanks for the help, guys :mrgreen: I actually ended up finding how to make it work, a friend of mine showed me. My mistake was trying to put the $ next to pov in the Character definition; it's supposed to go at the beginning of the line. After doing that, everything works great. :mrgreen:

But, Soraminako, thanks a bunch for the player_name.strip() and %(player_name)s functions! (Is that S after the close-paren necessary for that to work, or would that just make an S appear after the player's name?)

The issue remains, though, of the bold names. I sure hope that's fixable, probably in options.rpy or something...

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Making character names not bold (User input names resolv

#5 Post by Aleema »

Code: Select all

style.say_label.bold = False
There you go.

Variasaber
Newbie
Posts: 16
Joined: Sat Sep 24, 2011 11:35 pm
Completed: Ex Nihilo Unum (http://users.wpi.edu/~bmoriarty/imgd100 ... loUnum.rar)
Organization: 12000 Bombs
Location: Worcester Polytechnic Institute
Contact:

Re: Making character names not bold (User input names resolv

#6 Post by Variasaber »

Aleema wrote:

Code: Select all

style.say_label.bold = False
There you go.
Excellent! Thanks very much!

Since that's a style modifier, I suppose it belongs in options.rpy, but I'm guessing such settings can also be put in script.rpy if the setting were to change partway through the game.

I'll have to do some more exploring before I ask anything else; I don't want to waste anyone's time with things I could have easily discovered on my own. But once again, thanks a ton for everything, you guys! :mrgreen:

Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: Setting Character names from user input, and something e

#7 Post by Soraminako »

Variasaber wrote:[...]Soraminako, thanks a bunch for the player_name.strip() and %(player_name)s functions! (Is that S after the close-paren necessary for that to work, or would that just make an S appear after the player's name?)
The "s" is necessary. I wondered the same thing at first too. XD Code is weird like that...
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: User input names, making character names not bold [RESOL

#8 Post by Aleema »

If you're wondering why, there's an FAQ entry on it. The S stands for "string".

HikariYamino
Newbie
Posts: 7
Joined: Fri Apr 22, 2011 3:04 pm
Contact:

Re: Setting Character names from user input, and something e

#9 Post by HikariYamino »

Variasaber wrote:Thanks for the help, guys :mrgreen: I actually ended up finding how to make it work, a friend of mine showed me. My mistake was trying to put the $ next to pov in the Character definition; it's supposed to go at the beginning of the line. After doing that, everything works great. :mrgreen:

But, Soraminako, thanks a bunch for the player_name.strip() and %(player_name)s functions! (Is that S after the close-paren necessary for that to work, or would that just make an S appear after the player's name?)

The issue remains, though, of the bold names. I sure hope that's fixable, probably in options.rpy or something...
Wait!!! Uhh, i still can't do it... Can you copy and paste the correct code here that you used?? There seems to be an error in everything i did OTL

kiriyamiko
Newbie
Posts: 2
Joined: Sat Nov 12, 2011 8:04 pm
Contact:

Re: User input names, making character names not bold [RESOL

#10 Post by kiriyamiko »

Hi. I'm new to all this, and I know this was resolved but i followed the code exactly (I think. If there's something I'm doing wrong please tell me.)

Code: Select all

$ player_name = renpy.input("I dunno. What is it then?")
$ player_name = player_name.strip()
if player_name == "":
    $ player_name="Shou"
and i put the defining like this

Code: Select all

define p = DynamicCharacter("player_name", color="#c8ffc8")
however, when i test out my visual novel and use %(player_name)s , instead of the name i inputted, It's say "Nice to meet you %(player_name)s".
No name just the code.
I've been driving myself crazy, does anyone have an idea of what I've done wrong/ should be doing?

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: User input names, making character names not bold [RESOL

#11 Post by Aleema »

Do you have the newest Ren'Py? If so, the variable format has changed. Now you just put [brackets] around it. The FAQ entry should be updated to explain more.

kiriyamiko
Newbie
Posts: 2
Joined: Sat Nov 12, 2011 8:04 pm
Contact:

Re: User input names, making character names not bold [RESOL

#12 Post by kiriyamiko »

Aleema wrote:Do you have the newest Ren'Py? If so, the variable format has changed. Now you just put [brackets] around it. The FAQ entry should be updated to explain more.
You are a life saver and I love you :|
Thank youuuuuuuuu <3

ebi brain
Regular
Posts: 193
Joined: Thu Nov 11, 2010 1:10 pm
Organization: Zettai Rookie Project
Contact:

Re: User input names, making character names not bold [RESOL

#13 Post by ebi brain »

Sorry to bump an older thread, but I'm having the same problem as kiriyamiko...
and I don't really understand what I have to put brackets around:/

if someone could show an example, I'd be really grateful...
Since I have our site RSI, I used speech recognition by, sometimes this means I'll make some mistakes. :D

My sketchbook - Come yell at me :D

manga_otaku
Veteran
Posts: 413
Joined: Fri May 20, 2011 1:27 pm
Completed: [KN] Saving Project: Blind? (Part One)
Contact:

Re: User input names, making character names not bold [RESOL

#14 Post by manga_otaku »

Instead of the old %(player_name)s to show the players inputted name, you now use square brackets.
To show the chosen name when using the character pov, you would put:

Code: Select all

"My name is [player_name]"
Projects:
WIP|[KN] Day Of Reckoning|
Completed|[KN] Saving Project Blind: Part One|[KN] Saving Project Blind: Part Two|[KN] Saving Project Blind: Final Part|
Is available to help with proof-reading (Grammar freak...) Maybe voice-acting in the near future x]

ebi brain
Regular
Posts: 193
Joined: Thu Nov 11, 2010 1:10 pm
Organization: Zettai Rookie Project
Contact:

Re: User input names, making character names not bold [RESOL

#15 Post by ebi brain »

Aaaah now I get what I did wrong, I kept the % and s.
Thanks so much.
Since I have our site RSI, I used speech recognition by, sometimes this means I'll make some mistakes. :D

My sketchbook - Come yell at me :D

Post Reply

Who is online

Users browsing this forum: Bing [Bot]