FANDOM


When I receive ()
The -when I receive - -) block
Category Control
Type Hat
Disabling a project

"When I receive" stops a simple script

The When I Receive () is a Hat Block and a Control Block that allows sprites to listen for broadcasts sent by the broadcast () and broadcast () and wait blocks. Since there is no way to directly pass arguments through the block, it is difficult to broadcast messages intended for select sprites only.

Use with broadcast () and waitEdit

The Broadcast () and wait block sends a broadcast and pauses execution of a script until all receiving scripts that execute on the broadcast have stopped running. For this reason it is a good idea to be careful about the ways forever loops and such are used on receiving scripts.

Broadcasting to specific spritesEdit

Because Scratch 1.4 does not permit argument-passing in any form, directing a message at a single sprite is not a straightforward thing to do. However, it is fairly simple to simulate this functionality with a few global variables. These variables can store data that would otherwise be placed inside the non-existent message arguments. If an argument can pertain to only one sprite that will receive the broadcast (see Counting Sprites), then it can be targeted specifically at that sprite. For instance, a script might set a global variable like so:

Wir1

Then, certain sprites listening for the "hide selected sprite" broadcast would all receive it. However, since the broadcast script is checking the global "selected sprite" variable against the sprite's "my unique number" variable, only one sprite will act on the broadcast. When I Receive


Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.