Revision as of 19:55, 9 December 2018 by InterwikiBot (talk | contribs) (Adding interwikis.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The correct title of this article is Costume # (block). The Scratch Wiki uses this different title because of technical restrictions.
This article is about the block. For more information on the value this block reports, see Costume Number (value).
Costume #
2.0 Costume Number.png
Category Looks
Type Reporter
Introduced in Scratch 1.2

The Costume # block is a Looks Block and a Reporter Block. The block holds its sprite's current costume number. Since this block is for both sprites and the Stage, and sprites have costumes while the Stage has backgrounds, there needs to be two different versions of the block. One for sprites and one for the Stage. The version for the Stage is Background #. Each version can not be used as a substitute for the other version. If tried, the script will not run.

This block can be displayed as a Stage monitor.

Example Uses

As this block holds the costume number of sprites, it is widely used when something must happen if a sprite is at a specific costume. Some more common uses:

  • Stopping the project once a health sprite reaches the costume for zero health
if <(costume #) = []> then//Zero health costume number goes here.
stop [all v]
end
  • Checking if a sprite is at its last costume
if <(costume #) = []> then//Last costume number goes here.
. . .
end
  • Setting a variable to the current costume
set [variable v] to (costume #)

Workaround

Main article: List of Block Workarounds

This block can simply be replicated with the following code:

([costume # v] of [wanted sprite v])

However, the only way to obtain the same sprite that is selected within the block's attribute is to create the block in another sprite and drag it into the desired. Sprites cannot select themselves from a drop-down list, though other sprites can and then copy the block into the original sprite.

See Also