"Setting and Showing Variables": Chapbook (v1.0.0)

Summary

In Chapbook all variables are initialised and/or updated within the Vars Section of a passage, this section is always added at the beginning of the passage and there can only be one such section per passage.

The Vars Section is separated from the passage's normal text by two dashes (--), and you can display the contents of a variable using {insert} markup.

Note: Because you can [embed the contents of one passage within another](https://klembot.github.io/chapbook/guide/modifiers-and-inserts/embedding-passages.html) using the ```{embed passage:}``` insert, it is possible to update a variable using _Vars Section_ a child passage.

Live Example

Download: Live Example

Twee Code

:: StoryTitle
Setting and Showing Variables in Chapbook

:: Start
numberVariable: 5
wordVariable: "five"
phraseVariable: "The value"
--

{phraseVariable} is {numberVariable} and {wordVariable}.

{embed passage: "Increment number"}

The number variable was incremented by one to {numberVariable}.

:: Increment number
numberVariable: numberVariable + 1
--

Download: Twee Code

results matching ""

    No results matching ""