Which chapter element would you like to add?

Random Draws

Chapter 4 by Friedman Friedman

Random Draws

Random Draws let a reader press a button and receive one outcome from an author-written list. They work well for cards, clues, encounters, loot, prompts, and other moments where any listed result should be possible.

Preview

Select Draw a clue to see one of these outcomes. A repeatable draw changes its button to Draw again after the first result.

The result stays on the page until the reader draws again or reloads the chapter. Reloading a repeatable draw returns the card to its starting state.

Copyable syntax

Put the opening and closing tags on their own lines. Put each possible result on one source line between them:

{draw "Draw a card"}
The Key
The Lantern
The Storm
{enddraw}

The quoted text becomes the first button label. After the first selection, the reader sees one outcome and can use Draw again.

Keep one result for the browser session

Add once after the quoted label when the reader should receive only one result during the current browser session:

{draw "Consult the deck" once}
The Tower
The Moon
The Star
{enddraw}

After the selection, the button changes to Drawn and cannot be used again. CHYOA restores the same result after a reload or a return to the chapter during that browser session. A later browser session can draw again.

The ordinary repeatable and browser-session forms work without an active game and do not change Game State.

Save the result to Game State

To use a drawn result in later text or branches, first create a Text or Dropdown game variable as described in Reader and Game Variables. Add as game:variable_name after the label, then give each outcome a stable quoted value and a reader-facing result:

{draw "Draw a card" as game:card once}
"key" => **The Key** — A locked path opens.
"lantern" => **The Lantern** — Something hidden is revealed.
"storm" => **The Storm** — Trouble arrives.
{enddraw}

If The Key is selected, the reader sees the formatted result and CHYOA saves key in the card variable. The quoted value and => are not displayed. Use the exact game-variable name. For a Dropdown, each quoted value must be one of its configured choices.

A saved draw needs an active game. Until the reader starts one, the control is unavailable and shows Start game. A successful draw refreshes Game State, inventory, and continuation choices immediately, so the result can affect the current chapter without a reload:

{if game:card = "key"}
The locked door opens.
{endif}

Without once, the reader can draw again and replace the saved value. With once, the result and used state belong to that saved game and return with the chapter. Going Back past the draw may restore the variable's earlier value, but it does not make the once-only draw available again. Returning to the chapter still shows the original drawn outcome as Drawn without applying it a second time. Reset Game or Start Over begins a fresh game in which it can be used again.

Chances and repeated outcomes

A Random Draw needs from two through 100 outcomes. Every outcome line is equally likely, and each selection is independent, so the same result can appear twice in a row.

Repeating an identical outcome line gives that result another position and therefore a greater chance of being selected. In a saved draw, repeat the same complete value-and-result line. Do not assign one quoted value to different visible results, because the saved value must identify its result clearly.

Formatting, limits, and combinations

Blank lines may separate outcomes, but every outcome must contain visible text on one physical line. Inline emphasis, links, and inline code are supported. Headings, block quotes, lists, dividers, images, raw HTML, and active chapter tags are not outcomes. Do not prefix an outcome with a dash or another list marker.

A complete Random Draw can sit inside a reveal, code lock, or conditional passage. Do not place a draw inside another Random Draw, chat bubble, email card, or ordering puzzle, and do not place those blocks inside a draw. Each outcome is a result line, not a container for another interactive element.

Chapter word totals count the visible outcome prose. Draw tags, button labels, saved values, arrows, and once do not add to that total.

Before publishing

  • Put {draw ...} and {enddraw} on separate lines by themselves.
  • Include from two through 100 visible one-line outcomes.
  • Test the repeatable and once behavior you chose.
  • Check whether repeated lines give any result more weight than intended.
  • For a saved draw, verify the exact Text or Dropdown variable name and every saved value.
  • Start a test game and confirm that a saved result refreshes any conditional text or continuation that uses it.
Start your own immersive adult AI roleplay story
Ad

You've reached the end of this Guide topic.

  • No further chapters
Back Start Over View Story Map

0 comments