m (How to Write it in the Forums or Wiki)
m (uh, improved according to Scratch Wiki:Style Guide I guess)
Line 9: Line 9:
 
The '''When I Receive ()''' [[Blocks|block]] is an [[Events Blocks|Events block]] and a [[Hat Block|Hat block]]. [[Script]]s that begin with this block will be invoked once the specified [[broadcast]] has been sent by a calling script.
 
The '''When I Receive ()''' [[Blocks|block]] is an [[Events Blocks|Events block]] and a [[Hat Block|Hat block]]. [[Script]]s that begin with this block will be invoked once the specified [[broadcast]] has been sent by a calling script.
  
If a [[Forever_(block)|Forever]] block is sending the broadcast faster than the attached script can finish running, the script will restart without reaching the blocks at the end. This can be avoided by using [[Broadcast () and Wait]].
+
If a [[Forever (block)|Forever]] block is sending the broadcast faster than the attached script can finish running, the script will restart without reaching the blocks at the end. This can be avoided by using [[Broadcast () and Wait]].
 
 
==How to Write it in the Forums or Wiki==
 
<code>when I receive [message1 v]</code>
 
  
 
==Example Uses==
 
==Example Uses==

Revision as of 08:34, 14 November 2017

When I Receive ()
2.0 When I Receive ().png
Category Event
Type Hat

The When I Receive () block is an Events block and a Hat block. Scripts that begin with this block will be invoked once the specified broadcast has been sent by a calling script.

If a Forever block is sending the broadcast faster than the attached script can finish running, the script will restart without reaching the blocks at the end. This can be avoided by using Broadcast () and Wait.

Example Uses

Broadcasts are used to invoke scripts when certain evaluations are met; for scripts to activate once the broadcast is sent, those scripts must wear the When I Receive () block. Some common uses are:

when I receive [Failure v]
show
wait (3) secs
change [color v] effect by (25)
stop [all v]
  • Hiding select sprites when a certain condition is met under a particular evaluation
when I receive [broadcast v]
hide
  • When a scene must be set
when I receive [next background v]
next costume
  • Effective communication with scripts or sprites
when gf clicked
say [Hi!] for (1) secs
broadcast [communicate v]
when I receive [communicate v]
say [Hi!] for (1) secs
when I receive [run v]
. . .
broadcast [run v]
  • Winning a game
when I receive [win v]
say [You win!] for (2) secs

See Also