Show default name on screen

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
LittleAngel22
Newbie
Posts: 8
Joined: Sat Mar 12, 2022 7:43 pm
Contact:

Show default name on screen

#1 Post by LittleAngel22 » Sun Mar 13, 2022 12:56 pm

Hi! I'm practicing how to make a screen for the player to choose their own name and it's been working well, but I'd like to improve this a little bit more.

I would like the player to be able to see the character's default name on screen and, if desired, to be able to erase it and write their own. But I don't know how to do it. Anyone could help me?

Now my name screen looks like this:

Image

But I want it looks like this:

Image

The code that I used to make my screen: https://www.reddit.com/r/RenPy/comments ... urce=share

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1882
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Show default name on screen

#2 Post by Ocelot » Sun Mar 13, 2022 1:27 pm

Input screen element takes default property, which controls default text present in the input: https://www.renpy.org/doc/html/screens.html#input
< < insert Rick Cook quote here > >

LittleAngel22
Newbie
Posts: 8
Joined: Sat Mar 12, 2022 7:43 pm
Contact:

Re: Show default name on screen

#3 Post by LittleAngel22 » Sun Mar 13, 2022 3:28 pm

Ocelot wrote:
Sun Mar 13, 2022 1:27 pm
Input screen element takes default property, which controls default text present in the input: https://www.renpy.org/doc/html/screens.html#input

Okay, but can you tell me how to use this? Because I read this page several times, but I don't know how to get what I want. I know zero about coding and only very little about Renpy.

LittleAngel22
Newbie
Posts: 8
Joined: Sat Mar 12, 2022 7:43 pm
Contact:

Re: Show default name on screen

#4 Post by LittleAngel22 » Sun Mar 13, 2022 3:34 pm

Ocelot wrote:
Sun Mar 13, 2022 1:27 pm
Input screen element takes default property, which controls default text present in the input: https://www.renpy.org/doc/html/screens.html#input
This is my code:

Image

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1882
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Show default name on screen

#5 Post by Ocelot » Sun Mar 13, 2022 3:43 pm

First of all: if you are using InputValue, you cannot use default property, so you can delete it.

But it actually make it easier: you just need to set variable player_name to "Jamie". Find, where something like default player_name = "" or something similar. Just repalce the " " part with "Jamie"
< < insert Rick Cook quote here > >

LittleAngel22
Newbie
Posts: 8
Joined: Sat Mar 12, 2022 7:43 pm
Contact:

Re: Show default name on screen

#6 Post by LittleAngel22 » Sun Mar 13, 2022 4:18 pm

Ocelot wrote:
Sun Mar 13, 2022 3:43 pm
First of all: if you are using InputValue, you cannot use default property, so you can delete it.

But it actually make it easier: you just need to set variable player_name to "Jamie". Find, where something like default player_name = "" or something similar. Just repalce the " " part with "Jamie"

Worked like magic!! Thank you very much! If you don't mind, can I ask you something else? I would like to know how to make the text centered. I know how to position it on the screen, but when the player types, even though the cursor is in the center, the text goes to the right.

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1882
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Show default name on screen

#7 Post by Ocelot » Sun Mar 13, 2022 4:22 pm

add xanchor 0.5 to the input. You will have to change value of xpos since you are changing anchor, but it is trivial.
I assume that there is nothing else messing with input styles. If there is, it will be slightly harder.
< < insert Rick Cook quote here > >

LittleAngel22
Newbie
Posts: 8
Joined: Sat Mar 12, 2022 7:43 pm
Contact:

Re: Show default name on screen

#8 Post by LittleAngel22 » Sun Mar 13, 2022 4:35 pm

Ocelot wrote:
Sun Mar 13, 2022 4:22 pm
add xanchor 0.5 to the input. You will have to change value of xpos since you are changing anchor, but it is trivial.
I assume that there is nothing else messing with input styles. If there is, it will be slightly harder.
Unfortunately it doesn't seem to have worked. The cursor keeps going to the right instead of staying in the center when I delete the default name.

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1882
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Show default name on screen

#9 Post by Ocelot » Tue Mar 15, 2022 5:18 pm

You can try to set text_align to 0.5. Otherwise, you will need to check what style preferences are affecting your input and change them accordingly.
< < insert Rick Cook quote here > >

Post Reply

Who is online

Users browsing this forum: Google [Bot]