"Setting and Showing Variables": SugarCube (v2.18)#
Summary#
Variables, symbols starting with $
(for normal) or _
(for temporary), can be "set" using the <<set>>
macro in SugarCube.
$
is used for storing data throughout the story, and _
should be used for data only needed in the current passage. Using _
is useful for not wanting to accidentally overwrite variables elsewhere in the story. They can also help with debugging through not cluttering up the variables list of future passages.
Example#
Twee Code#
:: StoryTitle
Setting and Showing Variables in SugarCube
:: Start
<<set $numberVariable to 5>>
<<set $wordVariable to "five">>
<<set $phraseVariable to "The value">>
$phraseVariable is $numberVariable and $wordVariable.
<<set $numberVariable to $numberVariable + 1>>
$phraseVariable is $numberVariable and $wordVariable.