A box with a name

ReadingStart your game

A character forgets. It hops, it is hit, it runs, and it keeps no count of any of it. To remember something, a script needs a variable.

A box with a name

Think of a variable as a box with a name on it. You can put a number in the box, look at it later, and change it.

In Splat Script, a variable's name starts with @.

when I start
  @hits is 0

when I get hit
  @hits goes up by 1
LineWhat it does
@hits is 0Makes a box called @hits and puts 0 in it.
@hits goes up by 1Adds 1 to the number in the box.

After three hits, the box holds 3.

Using what is in the box

A variable is useful once you do something with it.

You canLike this
Say itsay "That is @hits!"
Ask about itif @hits is over 2
Change it@hits goes down by 1

Good to know

RuleWhat it means
You choose the namePick a name that says what is in the box, such as @hits or @coins.
Set it firstGive it a number when the game starts, so you know where it begins.
Everyone shares itEvery script in your game can see the same @hits. That will be handy later.

Finish this section

Tick Finished reading at the bottom of the page. Then press Next to see a slime that can count.