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

Using this in your own story

  1. Give every question its own passage with one link per answer choice.
  2. Route each answer to a different destination passage depending on whether it’s correct.
  3. Track anything you need (score, flags, inventory) in window.story.state and 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]]

Download the .twee file


← Previous: Random Flavor Text · All examples · Next: Restarting the Story →