How to Make the Player Set a Variable? [Twine 2.3.15, Harlowe 3.2.3]

Twine Version: 2.3.15
Story Format: Harlowe 3.2.3
I would like to make it so the player can set a variable as a string of text. In this case, I want the player to name their pet. Because the pet will appear throughout the story, I want the name to be a variable, so I can just type [$Dog_Name] to show the name of the pet. I don’t want to set the variable myself though, I want the player to type whatever they want. How would I do this?

You want an input box.

(input-box:bind $Dog_Name,"X===")

bind means whatever the reader will type will go into the $Dog_Name variable.
“X===” means how the input box will appear at screen: the number of characters (in this exemple four) means that each character covers an equal part of the passage length (in this exemple a quarter). Each ‘=’ means that part of the passage length won’t be in the inputbox. So “X===” means an input box of a quarter of the passage width, left-aligned.

There are useful options to consider:

(input-box:bind $Dog_Name,"X===",1,"Kerberos")

1 is the number of line, id est the height of your box.
“Kerberos” is the default name of the dog. You might want to add a default name or not.

Note that in Twine there’s an Input... button to help you create youe input boxes.

1 Like