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 JTen numbers per copy. They start at 0.
Switches 0 to 7Eight 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 valueSets one of the copy’s numbers.
Add to a value / Subtract from a valueAdds to it or takes away.
Compare a valueTests 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:

WhenStart of level
DoSet value A of Slime to 3
WhenLaser collides with Slime
DoDestroy LaserSubtract 1 from value A of SlimeSlime flashes for 0.3 seconds
WhenValue A of Slime is ≤ 0
DoDestroy SlimeAdd 100 to score

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 offTurn a switch on or off.
Flip a switchOn becomes off, off becomes on.
Switch is on / Switch is offTest 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.

WhenBird collides with PipeSwitch 0 of Bird is off
DoTurn switch 0 of Bird onShake the screen (6 pixels for 0.5 seconds)Play sound Hit

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

  1. Switch the toolbar to Expert.
  2. In a rule, click the cell under the sprite and choose Values → Set a value.
  3. Pick Value A from the list, type a number, press Add.
  4. To test it: + New event → the sprite → Values → Compare a value.

Still stuck?

Try the Chocobreak tutorial, open a sample game and read its rules, or look at the questions people ask.