0 votes
by (120 points)
I want the player to be asked a question which must be answered before moving on.  I have tried formatting the question in various ways, like this

(set $answer to prompt("Henry, Edward, Mary, Elizabeth.  Who is next?"))

(set $answer to prompt("What is your answer?"))
Your answer is (print: $answer)

(put: (prompt: "what is your answer?") into $answer)

and the result when I press play is like this

(set 0 to prompt("Henry, Edward, Mary, Elizabeth. Who is next?"))

(set 0 to prompt("What is your answer?"))
Your answer is 0

The (prompt:) macro needs 1 more value.►

How can I get this to work please?  I'm using the latest version of Twine, downloaded a few days ago

1 Answer

+1 vote
by (159k points)

You need to use the Question Tags to state the name and full version number of the story format you are using, as answers can vary based on that information. Based on the syntax of your examples I will assume you are using Harlowe v1.2.4, which is the default story from of Twine 2.

Please use the "Insert Code Snippet" button when including code examples in your question or comments.

The syntax of your (set:) macros and your (prompt:) macro are invalid, your first example should look something like the following.

(set: $answer to (prompt: "Henry, Edward, Mary, Elizabeth.  Who is next?"))
Your answer is (print: $answer)

... notice the full-colon after the set macro name, and that prompt is a macro and not a function call.

by (6.2k points)

Yes please put the format somewhere in the question, but this looks like harlowe, and please use the code snippet button.

Greyelf is right with the colon thing, however when it says the prompt macro needs another value, you need to do something like this:

(set: $answer to (prompt: "Henry, Edward, Mary, Elizabeth.  Who is next?","Answer"))
Your answer is (print: $answer)

The extra bit in quotation marks "which I suggested as answer" is what will already be in the text box, which will be highlighted, meaning when the player types something it will be replaced. 

by (120 points)
Thank you both for your slightly off putting answers.  I'm 80 years old and have been using Twine for just a few days, so maybe a bit more understanding would have been nice.
by (159k points)

I am sorry that you were put off by the contents of my answer.

The first paragraph of my answer was just a regurgitation of the request to "tag your question correctly" that appears at the top of the form that is displayed when you use the Ask a Question feature.

The second paragraph was what I though was a polite request (I did use Please) to mark your examples in a particular way so that they would be easier for others to locate and read, marking code example this way is a common practice on many sites.

You may of found the usage of words like syntax and invalid confronting if you don't have a programming background but they are the correct words to use when describing the structure of a programming  (scripting) language (like the difference versions of TwineScript that each Story Format includes).

by (8.9k points)

Congratulations for learning a new coding language aged 80, that's inspiring.  smiley

 
by (120 points)
Thanks Charlie. I’m managing quite well. In fact I’ve completed my first game. My biggest problem has been to discover just what commands are available. A detailed list of macros and functions would be useful but I haven’t found one yet. When I want to add something I Google it and see what comes up. A bit hit and miss but I’m getting there.
by (63.1k points)

@Mikemuk01

Here's the documentation for Harlowe: 

https://twine2.neocities.org

The reason story format is so important is because each format has its own features and documentation. The documentation for each format is maintained by the authors of those formats instead of the author of Twine, so they aren't actually on the Twine site and can sometimes be a bit hard to find. There's links (and some other info) on the wiki, though. 

...