Game Development Reference
Variables are an important part of programming. They allow you to store
informaion for later use and to transfer informaion between diferent objects.
A variable consists of two things; a name by which it is recognized and the
word/number/object that it stores.
The easiest way to think about it is to compare the variable to a jar of pickles in
a grocery store. The store clerk is the computer. He handles this jar and all the
other jars that are available in the store. The jar is a variable.
On the face of it they all look the same, like glass containers. It's hard to
disinguish one jar from another. That's why every jar has a label with a word
on it. This is the name of the jar/variable. Most probably, the name of the jar
will say something about what's in the jar. The jar of pickles, for example, will
be called "Pickles".
You move up to the counter and ask the clerk, "How many pickles are in the
Pickles jar?" and the clerk checks the jar, counts the pickles, and says, "There
are 9 pickles in the jar." You now know something about the content of the
Pickles jar. You feel like having a snack and decide to buy two pickles. After
you paid and received the pickles, you ask again, "How many pickles are in the
Pickles jar?" and the clerk counts the contents of the jar again (just to make
sure) and answers, "There are 7 pickles in the jar."
It's most common to store numbers in a variable, because computers like
to work with numbers, but variables can also contain names or even whole
objects. Scratch keeps it simple, though. Scratch variables can only contain
numbers or names/words.
Perhaps, it's beter to illustrate the explanaion of variables with the following screenshot: