Can I display the default character name when there is a prompt to choose one?
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.
Can I display the default character name when there is a prompt to choose one?
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.
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.
- isobellesophia
- Miko-Class Veteran
- Posts: 979
- Joined: Mon Jan 07, 2019 2:55 am
- Completed: None
- Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
- Organization: Friendly Teachers series
- Deviantart: SophBelle
- itch: Child Creation
- Location: Philippines, Mindanao
- Contact:
Re: Can I display the default character name when there is a prompt to choose one?
Easy, make a call screen and then use a yes and no prompt, you can try..
Re: Can I display the default character name when there is a prompt to choose one?
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
https://www.renpy.org/doc/html/input.html
https://www.renpy.org/doc/html/screens. ... nput#input
Re: Can I display the default character name when there is a prompt to choose one?
To answer your basic question... yes.
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....
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.
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
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
Re: Can I display the default character name when there is a prompt to choose one?
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?
Re: Can I display the default character name when there is a prompt to choose one?
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....
... 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:
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
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"
Re: Can I display the default character name when there is a prompt to choose one?
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.
Re: Can I display the default character name when there is a prompt to choose one?
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.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot]