My answer will work for Twine 2.1.3 and Sugarcube 2.18.0, but every other story format has ways of accomplishing the same thing, all of which you can probably find in the basic tutorials.
This is a variable:
$myVariable
You can use variables to store values, like strings, numbers and booleans. Usually you'll want to set up you're variables in a passage called StoryInit like this:
You can change the values of these variables later in the story using <<set>>, like @gellyfisher212 already pointed out. You can also combine this with a so called Setter Link:
[["Give me your money, dweeb!"|extortion][$fear += 1]]
This will create a link called "Give me your money, dweeb!", which sends the player to a passage called extortion, all the while adding 1 to $fear.
If you work with a lot of variables, it might be good to organize them using objects:
Comments
You need to state the name and full version number of the Story Format you are using, as answers can be different for each one.
This is a variable:
You can use variables to store values, like strings, numbers and booleans. Usually you'll want to set up you're variables in a passage called StoryInit like this:
You can change the values of these variables later in the story using <<set>>, like @gellyfisher212 already pointed out. You can also combine this with a so called Setter Link:
This will create a link called "Give me your money, dweeb!", which sends the player to a passage called extortion, all the while adding 1 to $fear.
If you work with a lot of variables, it might be good to organize them using objects:
To change the fear of our newly created NPC "Thomas", we would type something like this:
To then check, whether this change of fear would create a change in Thomas' status, we would use an <<if>> statement:
You can also combine all of this with a link, using a structure such as this: