How to print what I write?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By paseuda

Hello, I would like to know how to print what i write? I would like to make a window with character name and make player to write his/hers name there, save it as variable or constant and display on every other game screens.


There is a Box with text: “Choose Your Name”
and i click it and can write my character name. When I press “enter” it closed and save name. If I click again I can write diffrent name instead.

Can You tell me how to make it in GDScript in 2D window or send me a link to tutorial video?

:bust_in_silhouette: Reply From: tastyshrimp

You probably want to use Control nodes for that. There is a tutorial on the docs
about how to use them in general. In your specific case I believe you would want to use a TextEdit so the player can type.
After typing you are probably going to use a Button and connect it’s button pressed signal to save the name and close the dialog, you can check the [Title Screen tutorial] 4 in the docs for how to do that.
About where to save the name, it would probably go into a script at the top of your game tree so you don’t lose it while changing scenes. I won’t go into details here since it would be too long, but you can create a top level Node that is your game, which is responsible for the scene switching, title screen included, and maybe save states, and this node would also hold all the player information, including the name, because it is always there when the game is running.