Values and switches on objects
Every copy of a sprite has ten numbers and eight switches of its own, for remembering things like health or “already counted”.
What they are
A global value is one number for the whole game. A value on an object is different: every copy has its own. Twenty slimes can each have their own health in Value A. A door can remember “open” in Switch 0 while the next door stays shut.
| Values A to J | Ten numbers per copy. They start at 0. |
|---|---|
| Switches 0 to 7 | Eight on/off switches per copy. They start off. |
They are Expert only. Switch the toolbar to Expert to see them under a sprite’s Values sub-menu.
Values
| Set a value | Sets one of the copy’s numbers. |
|---|---|
| Add to a value / Subtract from a value | Adds to it or takes away. |
| Compare a value | Tests it, and picks only the copies that match. |
| Number each object (spread a value) | Gives each copy a different number (0, 1, 2…) so you can tell them apart. |
A slime with three hit points:
The picking does the hard work. The collision picks the one slime that was hit, so only its value A goes down.
Switches
| Turn a switch on / Turn a switch off | Turn a switch on or off. |
|---|---|
| Flip a switch | On becomes off, off becomes on. |
| Switch is on / Switch is off | Test it, and pick the copies that match. |
Wing It uses switch 0 on the bird to mean “crashed”, so a crash is only counted once and you cannot score after it.
In a formula
Value("Slime", "A") is the picked slime’s value A. Flag("Door", 0) is 1 when switch 0 is on and 0 when it is off. For a Counter, Value("Gems") with no letter is the number it shows. Show a value in a Text object with "HP: " + Str(Value("Hero", "A")).
How to
- Switch the toolbar to Expert.
- In a rule, click the cell under the sprite and choose Values → Set a value.
- Pick Value A from the list, type a number, press Add.
- To test it: + New event → the sprite → Values → Compare a value.