Let the player enter a name
On this page
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, “Shiori of the Library.”
Show an input field
- Select the line just before where you want the input field.
- Type “input” in the search box at the top of the parts panel, and double-click “Text input” in the results.
- In
variablein the right panel, write the name of the variable that stores the text (here,game.name). - In
prompt, write the heading shown above the input field (such as “Enter your name”). - To keep the player from confirming an empty field, check
required. - If needed, enter
placeholder(a hint shown faintly while the field is empty) andmax(the number of characters that can be entered).

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.

Use the entered name in the text
- While editing a dialogue or narration line, write
{= game.name}where you want the name, and press ⌘Enter to confirm.

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

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

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."