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| Line | What it does |
|---|---|
@hits is 0 | Makes a box called @hits and puts 0 in it. |
@hits goes up by 1 | Adds 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 can | Like this |
|---|---|
| Say it | say "That is @hits!" |
| Ask about it | if @hits is over 2 |
| Change it | @hits goes down by 1 |
Good to know
| Rule | What it means |
|---|---|
| You choose the name | Pick a name that says what is in the box, such as @hits or @coins. |
| Set it first | Give it a number when the game starts, so you know where it begins. |
| Everyone shares it | Every 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.

