From Test-Scratch-Wiki
- The correct title of this article is Costume # (block). The change of name is due to technical restrictions.
- This eng is about the block. For more information on the value this block reports, see Costume Number (value).
Costume # | |
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
For sprites |
Say () for () Secs
• Say () • Think () for () Secs • Think () • Show • Hide • Switch Costume to () • Next Costume • Switch Backdrop to () • Change () Effect by () • Set () Effect to () • Clear Graphic Effects • Change Size by () • Set Size to ()% • Go to Front • Go Back () Layers • Costume # • Backdrop Name • Size |
For the Stage |