# Let the player enter a name

> Have the player type text, store it in a variable and use it in the story

To let the player decide something like the main character's name, show an input field and store what they type in a variable. You can then show that variable inside dialogue and narration.

The examples on this page use the project you make in the [tutorial](/en/tutorial/), "Shiori of the Library."

## Show an input field

1. Select the line just before where you want the input field.
2. Type "input" in the search box at the top of the parts panel, and double-click "Text input" in the results.
3. In `variable` in the right panel, write the name of the variable that stores the text (here, `game.name`).
4. In `prompt`, write the heading shown above the input field (such as "Enter your name").
5. To keep the player from confirming an empty field, check `required`.
6. If needed, enter `placeholder` (a hint shown faintly while the field is empty) and `max` (the number of characters that can be entered).

![The "Text input" part, with the variable, prompt and required fields.](/shots/en/h-name-input-part.webp)

Variables that start with `game.` go into the save data, so the name is still there after loading. Text you write in `initial` is already in the field when it appears.

In the game, a heading, an input field and an OK button appear, and the story doesn't go on until the player confirms. Pressing Enter also confirms. If `required` is checked, OK can't be clicked until something is typed.

![The game screen. The input field and the OK button.](/shots/en/h-name-input-game.webp)

## Use the entered name in the text

1. While editing a dialogue or narration line, write `{= game.name}` where you want the name, and press ⌘Enter to confirm.

![Writing {= game.name} while editing a dialogue line.](/shots/en/h-name-input-say.webp)

In the block view, the `{= …}` part is shown as the variable's name.

![The block view. game.name is shown in the dialogue.](/shots/en/h-name-input-blocks.webp)

In the game, it's replaced with the name that was entered.

![The dialogue after entering "Haruka."](/shots/en/h-name-input-game2.webp)

If you select a line after the input field, the preview shows the name as empty, because the variable has no value yet. Open "Variables" below the preview and click the value of `game.name` to type a name on the spot and check how it looks (it isn't written to the file).

## In code

```
Shiori "Could you write your name on the library card?"
@text-input game.name prompt="Enter your name" placeholder=Name max=8 required=true
Shiori "{= game.name}, right? I'll write the return date on the card too."
```
