I tried to find a simple formula for prompt that works like textinput.

0 votes
asked Dec 4 by Kham (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 Dec 4 by Chapel (33,870 points)
(put: (prompt: "What's your name?", "") into $name)
Your name is $name.


(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 Dec 4 by Kham (140 points)
Would it be possible to get a quick example?  I'm not much of a tech.
commented Dec 4 by Chapel (33,870 points)
edited Dec 4 by Chapel
?? There are two examples in my answer.
0 votes
answered Dec 4 by greyelf (43,790 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)
(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.

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.