0 votes
by (120 points)
Hello everyone. I hope someone can help me. I'm using Twine 2 and Sugarcube 2 to write my very first text adventure. It's going really well, I have over 35 pages so far and am really excited, but there are a couple of things I can't seem to understand or find solutions for. I'm autistic and have ADHD so it's a struggle to focus sometimes.

The player has to answer a riddle. He has 2 choices, A, B and C. How can I make it so that if you enter A and B it's the wrong answer and C is the right answer and you can proceed?

And how do I allow the player to pick up points along the way?

1 Answer

0 votes
by (154k points)

And how do I allow the player to pick up points along the way?

You can use a $points story variable to track this, you can also use a story variable to track if the Reader correctly answered the riddle.

The following example consists of X Passages in your story.

1. Use a <<set>> macro to initialise your $points story variable within a special passage named StoryInit.
You should also initialise the story variable being used to track if the Reader answered the riddle correctly, I will be using a Boolean variable named $knewRiddle to do that. This variable will equal true is the answer is correct and false if it is not, by default we assume it is not.

<<set $points to 0>>
<<set $knewRiddle to false>>


2. Use Links within the Passage containing the riddle to offer potential answers.
You can use a Link With Setter to handle the selection of the correct answer to the riddle.

Three eyes have I, all in a row; when the red one opens, all freeze.

[[A. Wrong Answer 1|Next Passage]]
[[B. Traffic light|Next Passage][$knewRiddle to true]]
[[C. Wrong Answer 2|Next Passage]]


3. Check if the Reader knew the riddle's answer in the Next Passage.
You can use an <<if>> macro to check the current value of the $knewRiddle story variable and a <<set>> macro to increment then $points story variable if the Reader answered correctly,  and a related <<else>> macro to display a message if they answered incorrectly.

<<if $knewRiddle>>
	You correctly answered the riddle!
	<<set $points += 1>>
	It seems that you don't know the answer to that riddle!


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.