Can I display the default character name when there is a prompt to choose one?

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
Ace94
Regular
Posts: 89
Joined: Sat Apr 08, 2017 4:22 pm
Contact:

Can I display the default character name when there is a prompt to choose one?

#1 Post by Ace94 » Thu Nov 07, 2019 10:56 am

Like when I ask the player to type their name for a character can I have an already typed name in there for them to see and they can either hit enter if they like it or delete it and type their own.

I know how to do a default one, but I don’t know how to show it typed in there when the player makes the choice.

User avatar
isobellesophia
Miko-Class Veteran
Posts: 707
Joined: Mon Jan 07, 2019 2:55 am
Projects: Maddox's Everyday Talk! (13+ Unreal version), Maddox Everyday Talk! (3+ Real-Friendly version)(Upcoming 2020)
Organization: Friendly Teachers series
itch: .......
Location: Philippines, Mindanao
Contact:

Re: Can I display the default character name when there is a prompt to choose one?

#2 Post by isobellesophia » Thu Nov 07, 2019 11:07 am

Easy, make a call screen and then use a yes and no prompt, you can try..
I am a friendly user, please respect and have a good day..


Working on a talking simulation game for everyone, except children.

Maddox Everyday Talk!
Is my very very main project, not contain 13 below.

Main project here viewtopic.php?f=43&t=56564
Image

philat
Eileen-Class Veteran
Posts: 1656
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Can I display the default character name when there is a prompt to choose one?

#3 Post by philat » Thu Nov 07, 2019 10:04 pm

Set the default. (Don't know if you're using renpy.input or screens. Either way, it's similar.)

https://www.renpy.org/doc/html/input.html
https://www.renpy.org/doc/html/screens. ... nput#input

Woetoo
Newbie
Posts: 18
Joined: Sat Feb 09, 2019 9:48 am
Contact:

Re: Can I display the default character name when there is a prompt to choose one?

#4 Post by Woetoo » Fri Nov 08, 2019 7:21 am

To answer your basic question... yes.

Code: Select all

default player_name = "Unnamed"

label start:

    scene black with fade

    $ player_name = renpy.input("What is your name?", default="Simon")
    $ player_name = player_name.strip() or "Simon"

    "Welcome [player_name]"
    "<<< THE END>"
    
    return
This seems to be what you've described. Where "Simon" is already pre-filled in for the player to either accept as the default or remove and type another name.

The second line serves two purposes... It remove leading and trailing spaces (So someone doesn't end up with a name like " Tom ". It also says that if the player removes the name completely and presses enter on a blank name... it will still use "Simon".

However, I personally don't like this style of name input. For those of us who regularly use a different name... it means deleting the old name so we can type in our new one. I prefer the approach where the field is blank to start with and if the player doesn't pick a name - they get the default one. Extra points if the game actually tells you what that default name is so you can make an informed choice.

This is what I would code....

Code: Select all

default player_name = "Unnamed"

define std_player_name = "Robert"

label start:

    scene black with fade

    $ player_name = renpy.input("What is your name? {i}(Just press ENTER for '[std_player_name]'){/i}", length=20)
    $ player_name = player_name.strip() or std_player_name

    "Welcome [player_name]"
    "<<< THE END>"
    
    return
Where "std" is just my shorthand for "standard" and avoids me having variable names like "default_player_name", which could be so easily misread when quickly scanning through the code. And "length=20" just stops annoying players using names like "sdfsdlkjfdljsdlfkjsdlkfjdslfjdsflkjsdflkjsdflksjdflkdsfjlkdsjflsdjfsldkfgj". They can still use stupid names... but at least they're unlikely to make a conversation line so long it overlaps other parts of the game UI.

Ace94
Regular
Posts: 89
Joined: Sat Apr 08, 2017 4:22 pm
Contact:

Re: Can I display the default character name when there is a prompt to choose one?

#5 Post by Ace94 » Fri Nov 08, 2019 9:15 am

Woetoo wrote:
Fri Nov 08, 2019 7:21 am
To answer your basic question... yes.
Thank you very much for explaining it that well!

Can I ask another question? Is it possible to change a color in which the name is typed with? If I have different colors in the dialogue and names for different characters when they are defined, can I make the prompt asking for the player to pick a name in the color associated with the said character?

Woetoo
Newbie
Posts: 18
Joined: Sat Feb 09, 2019 9:48 am
Contact:

Re: Can I display the default character name when there is a prompt to choose one?

#6 Post by Woetoo » Fri Nov 08, 2019 12:43 pm

I'm guessing the answer is yes... But I personally don't know how to do it.
I'm guessing it would involve altering the style of the displayable element of either the input_prompt or the "input" objects and then maybe forcing a rebuild of the styles used by the game.

I tried this....

Code: Select all

    $ style.input_prompt.color = "#884488"
    $ style.rebuild

    $ player_name = renpy.input("What is your name?", default="Simon")
    $ player_name = player_name.strip() or default_player_name
... but it didn't work.
Screens and styles are still kinda voodoo to me sadly.

I will also add that I don't think swapping the text color of either the text itself or the input value will be as pretty as you're hoping it will be if you do it "per character". I could be wrong though.

If you're just unhappy with the current colors... You can change those easily enough.

Either... Change the project's overall color scheme.

Go into the RenPy launcher, highlight your project and click on "Change/Update GUI". Pick "Choose new colors, then regenerate image files" and Continue.
Then pick whatever replacement style you want for you whole project.

This will impact more than just your input boxes. But this choice when you were first setting up your project is likely why you don't like the colors now.

Alternatively, if you're happy with the colors everywhere else... just not the input box. Change the colors used for the input panel

Edit the screens.rpy file.
Find the style input_prompt: and/or the style input: and add a color parameter.

Something like:

Code: Select all

style input_prompt:
    xalign gui.dialogue_text_xalign
    properties gui.text_properties("input_prompt")
    color "#FF0000"

style input:
    xalign gui.dialogue_text_xalign
    xmaximum gui.dialogue_width
    color "#FF0088"

Ace94
Regular
Posts: 89
Joined: Sat Apr 08, 2017 4:22 pm
Contact:

Re: Can I display the default character name when there is a prompt to choose one?

#7 Post by Ace94 » Sat Nov 09, 2019 5:08 am

Yeah. I know how to change the overall colors, but I was hoping to be able to change the prompt input for each individual characters since they have unique colors assigned to them when a dialogue happens.

Woetoo
Newbie
Posts: 18
Joined: Sat Feb 09, 2019 9:48 am
Contact:

Re: Can I display the default character name when there is a prompt to choose one?

#8 Post by Woetoo » Sat Nov 09, 2019 5:47 am

Ace94 wrote:
Sat Nov 09, 2019 5:08 am
Yeah. I know how to change the overall colors, but I was hoping to be able to change the prompt input for each individual characters since they have unique colors assigned to them when a dialogue happens.
As I say, I'm sure it's likely possible.

Hopefully someone much more familiar with screens, styles and renpy.input() will read this far down the thread and figure out what I couldn't.

Post Reply

Who is online

Users browsing this forum: No registered users