m
m (Just fixing some wording mistakes.)
 
(4 intermediate revisions by one other user not shown)
Line 2: Line 2:
 
| name      = When I Receive ()
 
| name      = When I Receive ()
 
| image      = when I receive [message1 v]
 
| image      = when I receive [message1 v]
| sb        = yes
+
| sb        = 3.0
 
| category  = [[Event Blocks|Event]]
 
| category  = [[Event Blocks|Event]]
 
| type      = [[Hat Block|Hat]]
 
| type      = [[Hat Block|Hat]]
 
| default    = First [[broadcast]] (alphabetized)
 
| default    = First [[broadcast]] (alphabetized)
 +
| added      = [[Scratch 0.1|0.1]]
 
}}
 
}}
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 ()''' block is a [[Hat Block|hat block]] and an [[Events Blocks|events block]]. The block activates its script when the specified [[broadcast]] has been sent by a calling script.
  
 
If the same message is sent again while the script is still running, the script will restart without reaching the blocks at the end. Using the [[Broadcast () and Wait (block)|Broadcast () and Wait]] block can help to make a message script run over and over again.
 
If the same message is sent again while the script is still running, the script will restart without reaching the blocks at the end. Using the [[Broadcast () and Wait (block)|Broadcast () and Wait]] block can help to make a message script run over and over again.
Line 18: Line 19:
 
when I receive [Failure v]
 
when I receive [Failure v]
 
show
 
show
wait (3) secs
+
wait (3) seconds
 
change [color v] effect by (25)
 
change [color v] effect by (25)
 
stop [all v]
 
stop [all v]
Line 25: Line 26:
 
*Hiding select sprites when a certain condition is met under a particular evaluation
 
*Hiding select sprites when a certain condition is met under a particular evaluation
  
<scratchblocks>when I receive [broadcast v]
+
<scratchblocks>
hide</scratchblocks>
+
when I receive [broadcast v]
 +
hide
 +
</scratchblocks>
  
 
*When a scene must be set
 
*When a scene must be set
  
<scratchblocks>when I receive [next background v]
+
<scratchblocks>
next costume</scratchblocks>
+
when I receive [next background v]
 +
next costume
 +
</scratchblocks>
  
 
*Effective communication with scripts or [[sprite]]s
 
*Effective communication with scripts or [[sprite]]s
  
<scratchblocks>when gf clicked
+
<scratchblocks>
say [Hi!] for (1) secs
+
when green flag clicked
broadcast [communicate v]</scratchblocks>
+
say [Hi!] for (1) seconds
 +
broadcast [communicate v]
 +
</scratchblocks>
  
<scratchblocks>when I receive [communicate v]
+
<scratchblocks>
say [Hi!] for (1) secs</scratchblocks>
+
when I receive [communicate v]
 +
say [Hi!] for (1) seconds
 +
</scratchblocks>
  
 
*Creating [[Recursion#Recursion in Scratch 1.4|tail recursion]]
 
*Creating [[Recursion#Recursion in Scratch 1.4|tail recursion]]
  
<scratchblocks>when I receive [run v]
+
<scratchblocks>
 +
when I receive [run v]
 
. . .
 
. . .
broadcast [run v]</scratchblocks>
+
broadcast [run v]
 +
</scratchblocks>
  
 
*Winning a game
 
*Winning a game
Line 52: Line 63:
 
<scratchblocks>
 
<scratchblocks>
 
when I receive [win v]
 
when I receive [win v]
say [You win!] for (2) secs
+
say [You win!] for (2) seconds
 
</scratchblocks>
 
</scratchblocks>
  
Line 60: Line 71:
 
*[[Broadcast]]
 
*[[Broadcast]]
 
{{Events Blocks}}
 
{{Events Blocks}}
[[Category:Event Blocks]]
+
[[Category:Events Blocks]]
 
[[de:Wenn ich () empfange (Block)]]
 
[[de:Wenn ich () empfange (Block)]]
 
[[ja:() を受け取ったとき (ブロック)]]
 
[[ja:() を受け取ったとき (ブロック)]]
 
[[ru:Когда я получу ()]][[hu:() üzenet érkezésekor (blokk)]]
 
[[ru:Когда я получу ()]][[hu:() üzenet érkezésekor (blokk)]]

Latest revision as of 00:30, 3 March 2021

When I Receive ()
when I receive [message1 v]
Category Event
Type Hat
Introduced in 0.1

The when I receive () block is a hat block and an events block. The block activates its script when the specified broadcast has been sent by a calling script.

If the same message is sent again while the script is still running, the script will restart without reaching the blocks at the end. Using the Broadcast () and Wait block can help to make a message script run over and over again.

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. When a sprite activates a script from receiving a broadcast, it's current clones will also receive the broadcast and activate the same script individually. Some common uses are:

when I receive [Failure v]
show
wait (3) seconds
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 green flag clicked
say [Hi!] for (1) seconds
broadcast [communicate v]
when I receive [communicate v]
say [Hi!] for (1) seconds
when I receive [run v]
. . .
broadcast [run v]
  • Winning a game
when I receive [win v]
say [You win!] for (2) seconds

See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.