std/lesson

Predict mode and captions

# package lesson
use std/sim

Asked has
  set Question to ""
  set Choices to {}

Noted has
  set Text to ""

# Emit `Asked` with no choices; the player pauses and asks the viewer to predict
define Ask [q: text]
  emit (message Asked with Question q) by sim.Nobody

# Emit `Asked` with the choices `c`: 2 to 6 distinct, non-empty texts, else `bad-argument`; the player pauses and offers them
define Ask [q: text] choosing [c: list of text]
  emit (message Asked with Question q, Choices (choices c)) by sim.Nobody

# Emit `Noted`; the player shows a caption
define Note [t: text]
  emit (message Noted with Text t) by sim.Nobody

# Unexported: check `c` for `Ask … choosing` (used by it)
define choices [c: list of text] native "lesson.choices"

choices is not exported (a native, like look.delete). It returns c after checking it, and fails with bad-argument (lesson.Ask … choosing needs 2 to 6 different, non-empty choices) unless c has 2 to 6 distinct, non-empty texts, so choosing {} is never a second spelling of Ask [q: text].

Phrases

lesson.Ask [q: text]

Emit Asked with no choices; the player pauses and asks the viewer to predict

Gives
—
Contexts
main
Kind
phrase, written in Synod
Source
lesson/lesson.synod:12
Examples
lesson/predict

lesson.Ask [q: text] choosing [c: list of text]

Emit Asked with the choices c: 2 to 6 distinct, non-empty texts, else bad-argument; the player pauses and offers them

Gives
—
Contexts
main
Kind
phrase, written in Synod
Source
lesson/lesson.synod:16
Examples
lesson/predict

lesson.Note [t: text]

Emit Noted; the player shows a caption

Gives
—
Contexts
main
Kind
phrase, written in Synod
Source
lesson/lesson.synod:20
Examples
lesson/predict

Records

lesson.Asked

FieldType
Questiontext
Choiceslist of text

lesson.Noted

FieldType
Texttext

Examples

predict

Shows lesson.Note (a caption), lesson.Ask (a question) and lesson.Ask choosing (a multiple-choice question)

# package main
# Shows lesson.Note (a caption), lesson.Ask (a question) and lesson.Ask choosing (a multiple-choice question)
use std/lesson
use std/sim

define main
  lesson.Note "Three captions and questions follow."
  after 1s
    lesson.Ask "What will the next caption say?"
  after 2s
    lesson.Ask "Which comes first?" choosing {"The chicken", "The egg"}
  after 3s
    lesson.Note "There is no right answer here."
  sim.StopAt 4s