Ask the player’s name

By the end your game will ask for a name, wait for Enter, and say "Hello, Sam!" with whatever was typed.

What you need

The Text box is Advanced. Switch to Advanced mode.

Text box+ Add object → New → Text box. Grey hint while empty: Type your name. Most letters: 12. Name it Name box.
QuestionA Text saying What's your name?
GreetingA Text with empty Words, big size. Name it Greeting.
SoundClick.
NutHouse
The Text box settings: Grey hint while empty, Most letters and Box width

Build it

  1. Put the question near the top, the Name box under it, and the Greeting lower down.
  2. Events tab → + New event → 🎬 Game → Start of level. In Name box choose Start typing in it. Now the player can type straight away.
  3. + New event → Name box → The player presses Enter.
  4. In the Greeting cell choose Set the text. In Text, type exactly:
    "Hello, " + Text("Name box") + "!"
  5. Add Hide for the Name box and the question. Play Click.
  6. Press ▶ Play level. Type a name and press Enter.
WhenStart of level
DoStart typing in Name box
WhenThe player presses Enter in Name box
DoSet text of Greeting to "Hello, " + Text("Name box") + "!"Hide Name boxHide the questionPlay sound Click

How the formula works

Text("Name box") is what the player typed. Words in straight quotes are joined on with +. Click ƒx and open Objects → Name box to insert it without typing.

Why Enter, not Always

The player presses Enter is red. It happens once, when the typing is done. A rule that read the box every moment would greet half a name, letter by letter.

Make it yours

  • Keep the name for later: put the Greeting on every level, hidden, and set it again on Start of level. Or use a High scores table at the end with the same Text("Name box").
  • Shout it: "GO, " + Text("Name box") + "!" on the first game level.
  • Say no to empty names: add Compare two values Len(Text("Name box")) > more than 0.

Still stuck?

Try the Chocobreak tutorial, open a sample game and read its rules, or look at the questions people ask.