0 votes
by (130 points)
First of all: Hello everybody. I am glad to be here.

Second: I am using Sugarcube to create a quiz.

I want to mark the correct answers to be marked by a symbol which should not be printed when providing the answers.
So, for example, a correct answer would be written as "~true". However, on screen, the user should only see "true".
How do I get twine to display only "true", while still having "~true" to process the actual answer in the code?

1 Answer

+1 vote
by (68.6k points)

You may want to rethink whatever you're doing there as from the little you've mentioned it sounds like you could probably do better.

Regardless.  Assuming you're not going to use an extended character—meaning outside of Unicode's basic multilingual plane—for the symbol, then you may use the <String>.slice() method.  For example:

<<print $answer.slice(1)>>

That will print the story variable sans its first character—UTF-16 code unit, actually—and without modifying the original value.

by (130 points)
Thank you very much for the quick answer.

What method would you suggest to denote which answers are correct and which are not? I would want to have a multiple choice situation, with not only one, but up to four correct answers.
by (44.7k points)
edited by

You could use the "strikethrough" markup to indicate wrong answers, thus the only one(s) not struck through would be the right one(s).  That markup just looks like this:

Normal text ==strikethrough== more normal text.

Which would be displayed like this:

Normal text strikethrough more normal text.

Seems fairly clear to me, and avoids any problems red-green colorblind people might have if you colored the answers.

Hope that helps!  :-)

by (130 points)
This is definitely something I will do. Thank you very much for the suggestion!