In programming terminology, a variable is a container for a value that can change. In Twine, a variable is a way of storing and acting on data of some sort. Anything from a number to a series of characters can be stored in a variable. Unlike other code or text in a Passage, variables most commonly start with either the dollar sign ($) or the underscore (
_) in the Harlowe and SugarCube story formats.
Once created, story variables in Twine can be accessed from any passage at any time. They are globally accessible to all functionality everywhere.
All story formats (except Snowman) understand variables and translate them into their values when used by themselves in a Passage. To display their value, they can simply be included as part of any other text.
The value of the variable is $numberVariable.
It can often be useful to work with values in a more controlled manner. For this purpose, temporary variables can be used. They are locally accessible. They only exist while the current passage is shown. They start with an underscore (
Temporary variables can also be used to display their values with other text like Story Variables.
The value of the variable is _numberVariable.