Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to have a default name in case someone doesn't fill in the prompt I set?

I am making a story where the reader inserts their own name via a prompt. (Using Twine 2, Harlowe).
However, I have no idea how to put a default value for when the reader doesn't put anything in the prompt.

To illustrate what I mean (sort of) take this Twine 1 example:
<<set $playerName = prompt("Please enter your name","Jack")>>

It has an option to add a name, which in this case is "Jack". I guess you could say?

I'm using this for Twine 2 - Harlowe:
(set: $firstname to (prompt: "What's your name?"))

Any and all help will be appreciated. Thanks in advance.


  • You can use an (if:) macro to test if the reader entered a name and if they did not set a default:
    (set: $firstname to (prompt: "What's your name?"))
    (if: $firstname is "")[(set: $firstname to "Jack")]
    Your name is $firstname
  • @greyelf Thank you, thank you, thank you! I've been playing with macros all day and I couldn't figure it out.

Sign In or Register to comment.