0 votes
asked by (140 points)
Found (put: (prompt: "What's your name?") into $name) Your name is $name. on the web and it didn' work. Does someone have one?

2 Answers

+1 vote
answered by (54.9k points)
(put: (prompt: "What's your name?", "") into $name)
Your name is $name.

OR

(put: (prompt: "What's your name?", "Barry") into $name)
Your name is $name.

The (prompt:) macro requires two strings: the first is the question or prompt, the second is the default string for the answer, which you can make a default name or blank (by passing an empty string).

commented by (140 points)
Would it be possible to get a quick example?  I'm not much of a tech.
commented by (54.9k points)
edited by
?? There are two examples in my answer.
0 votes
answered by (114k points)

You need to use the Question Tags to indicate the name and full version number of the Story Format you are using, as answers can vary based on that information.

A. If you are using the 1.x series of Harlowe (eg. v1.2.4) then your example will work because that series only requires you to pass a single String parameter to the (prompt:) macro.

(put: (prompt: "What's your name?") into $name)
or
(set: $name to (prompt: "What's your name?"))

B. If you are using the 2.x series of Harlowe (eg. v2.0.1) then as explained in the (prompt:) macros documentation you need to pass two String parameters to that version of the macro.
There are two examples of how to use the 2,x series version of the (prompt:) macro in @Chapel's answer to your question.

notes:
1.  you can use either a (put:) macro or a (set:) macro to assign the returned value of the (prompt:) macro to a variable.
2. the 1.x series documentation for the (prompt:) macro incorrectly states you need two parameters.

Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...