One of the best ways you can help your reader/player connect to your story or game is by including them in it. Twine let's you quite easily ask a reader for their name and then insert that name into the story later via interaction with other characters.
As you might imagine, this will once again be done with variables, as seen in the examples below. The first example will ask for a name via a pop-up on the screen, while the second way is integrated into the text of the story. Which way you choose will depend on the flow of your story!
The example below is from a story (in progress) that takes place at the Allerton Estate in Central Illinois. It is a murder mystery in which the player will take on the role of a Pinkerton Detective who may (or may not) want to go by their real name. In the example below I am asking for both a First Name ($firstname) and Last Name ($lastname) since this will allow me to have other characters use a different address depending on their social status (e.g., the servants might use a formal address with the last name).
Setting a name for a player via a pop-up interface.
Here is the code in a copyable format!
(set: $firstname to (prompt: "insert here whatever question/prompt you want to use","I normally leave this blank between this set of quotation marks so that the box is empty when it first appears"))
When actually playing the game, this code will result in the following:
This is where variables will come to the rescue once again!! The snippet below shows the coding when the detective encounters Robert Allerton.
"Welcome to the Allerton Estate, $firstname!" says Robert Allerton, giving you a slight nod that shows he knows your true purpose for attending the weekend party.
The result in the game looks like this:
As noted above, I could have also easily had that character use the Last Name instead, or both names, depending on need. Easy as that!
This just requires a small change in the coding. The coding below uses an Input Box rather than a pop-up Prompt. This would allow for the asking of a single name or both, once again.
"Welcome to the Allerton Estate," said the butler. "Might I have your name?"
You respond with your name:
(input-box:2bind $Name,"=XX=","Type your name here")
In the game, this would result in the following:
Once again, later in the story you'd just need to add that variable into the appropriate places.
"Greetings, $Name and welcome to Allerton."