0 votes
by (200 points)

I want to use the prompt set and use the input to change to path. EG; 'do you feel brave enough?' and the player could type an answer like yes or no. But i want to check if the players types in yes, it would trigger an event, same with no.

i tried:

(set: $brave to (prompt: "yes or no","no")

(if: $brave is yes) [you're very brave]
(if: $brave is no) [you aren't very brave]

(as an example given)


Is this even possible or?

I'm using Harlowe 2.1.0 btw

1 Answer

0 votes
by (159k points)
selected by
Best answer

Please use the Question Tags to start the name and full version number of your Story Format, instead of including that information within the question itself.

The (prompt:) macro returns a String value, which means you need to use String values in your checks like so.

(set: $brave to (prompt: "yes or no", "no"))

(if: $brave is "yes")[you're very brave]
(else-if: $brave is "no")[you aren't very brave]
(else:)[You didn't enter either ''yes'' or ''no'' using lower case letters]

notes: there were some syntax and logic issues with your example:
1. Your (set:) macro call was missing the trailing close parenthesis.
2. You had a space character between your (if:) macros and their associated hooks.
3. Your second (if:) macro should be an (else-if:) macro because the conditional expressions of your two (if:) macros are related and only one of them can be true at any one time. (mutually exclusive)
4. Your logic isn't handling the situation where the end-user enters a value other than a lower case yes or no, and end-users can be tricky that way.