Audience: Beginner (no HTML/CSS/JS experience needed)
What this shows
Combining links, conditionals, and a running variable to build a simple quiz that tallies a final score.
How it works
window.story.state.correctAnswers = 0;sets up the running total once, inUserScript.- Each question is its own passage with two links, one for each answer
(
Yes/No). Each answer links to a different passage (e.g.Question1YesorQuestion1No). - The “correct” answer passages increment the counter with
<% s.correctAnswers++; %>; the “incorrect” ones don’t. - The final
Resultspassage displays the running total with<%= s.correctAnswers %>.
Using this in your own story
- Give every question its own passage with one link per answer choice.
- Route each answer to a different destination passage depending on whether it’s correct.
- Track anything you need (score, flags, inventory) in
window.story.stateand display or branch on it later.
Full source
:: StoryData
{
"ifid":"05BC25BA-547E-456F-9E57-89582F206B94"
}
:: StoryTitle
Yes or No Quiz in Snowman
:: UserScript[script]
window.story.state.correctAnswers = 0;
:: Start
Is the sky blue?
[[Yes->Question1Yes]]
[[No->Question1No]]
:: Question1Yes
<% s.correctAnswers++; %>
Correct!
[[Next question->Question2]]
:: Question1No
That's incorrect.
[[Next question->Question2]]
:: Question2
Is fire cold?
[[Yes->Question2Yes]]
[[No->Question2No]]
:: Question2Yes
That's incorrect.
[[See results->Results]]
:: Question2No
<% s.correctAnswers++; %>
Correct!
[[See results->Results]]
:: Results
You answered <%= s.correctAnswers %> out of 2 questions correctly.
[[Try again->Start]]
← Previous: Random Flavor Text · All examples · Next: Restarting the Story →