Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do I use "When I Receive" blocks?
- Tommy200721
-
1 post
How do I use "When I Receive" blocks?
I need help using those blocks so please help me!
- asivi
-
1000+ posts
How do I use "When I Receive" blocks?
I hope that some scratcher make some reliable and detailed tutorial project about broadcast and its applications.
In the meanwhile:
https://wiki.scratch.mit.edu/wiki/Broadcast
In the meanwhile:
https://wiki.scratch.mit.edu/wiki/Broadcast
- footsocktoe
-
1000+ posts
How do I use "When I Receive" blocks?
I need help using those blocks so please help me!
All the hat blocks are the same. They start a script.
Some ways to start a script…
green flag
key press
broadcast message
click on sprite
backdrop switches
When I receive starts the script when a sprite sends that message
Last edited by footsocktoe (June 17, 2017 02:43:50)
- WeirdoStary12IsBack
-
7 posts
How do I use "When I Receive" blocks?
first do “Brodcast Message 1” Then Click on another sprite Then pu the When i recive block
Example:
Example:
- enigmaworks
-
24 posts
How do I use "When I Receive" blocks?
The hat when I receive {message} is activated when a sprite, clone, or even the backdrop(itself or another in the project) broadcasts the message selected.
For example, something in the project could broadcast the message “Next Slide” when the space key is clicked, or “RickRoll” you when it is clicked, like this:
Then something else(sprite, clone or the backdrop) could receive those messages and change the Slide Variable, or rick roll you.
Since the are different messages, they will only activate when I receive{message} hats with the correct message selected, when it is broadcasted. The hat can also be used multiple times to do different things at the broadcast of the same message, for example also playing a dance animation and music when it is rickrolling you.
For example, something in the project could broadcast the message “Next Slide” when the space key is clicked, or “RickRoll” you when it is clicked, like this:
Then something else(sprite, clone or the backdrop) could receive those messages and change the Slide Variable, or rick roll you.
Since the are different messages, they will only activate when I receive{message} hats with the correct message selected, when it is broadcasted. The hat can also be used multiple times to do different things at the broadcast of the same message, for example also playing a dance animation and music when it is rickrolling you.
Last edited by enigmaworks (Jan. 24, 2021 15:58:07)
- Carsvroomboi
-
20 posts
How do I use "When I Receive" blocks?
The message blocks are to transfer code across sprites.
- SpectrumPenguin
-
46 posts
How do I use "When I Receive" blocks?
If you wanna use the “When I receive ()” block, please go to the Events
- BionicBoy554
-
1000+ posts
How do I use "When I Receive" blocks?
Broadcasts and “when I receive” blocks are basically just throwing stuff across sprites.
- kinosaurs515
-
1000+ posts
How do I use "When I Receive" blocks?
The broadcast block
connects to the “When I Recieve” block.
I hope this helps!
connects to the “When I Recieve” block.
I hope this helps!
- kexy321
-
45 posts
How do I use "When I Receive" blocks?
The “When I Receive” block is like a type of function that is global to the entire project. So you can use them. Here's an example:
From a sprite:
From another sprite:
The broadcast block executes the receive block that contains “Foo”
Also, one thing that broadcast and receive blocks do is that they can create multiple threads. And they also do not prevent a yield from happening. (Prevent a stop in the code from happening.)
If you wanted to stop code when a broadcast happens, simply use a “Broadcast and Wait” block
Let's add a broadcast and then a “Ask and Wait” block
The broadcast will not stop the script on it's place. It continues it.
Also, clones that contain the “When I Receive” block will also be executed. So make sure to take note of that.
I hope it taught you about broadcasts and receive blocks!
From a sprite:
From another sprite:
The broadcast block executes the receive block that contains “Foo”
Also, one thing that broadcast and receive blocks do is that they can create multiple threads. And they also do not prevent a yield from happening. (Prevent a stop in the code from happening.)
If you wanted to stop code when a broadcast happens, simply use a “Broadcast and Wait” block
Let's add a broadcast and then a “Ask and Wait” block
The broadcast will not stop the script on it's place. It continues it.
Also, clones that contain the “When I Receive” block will also be executed. So make sure to take note of that.
I hope it taught you about broadcasts and receive blocks!
Last edited by kexy321 (March 27, 2022 05:32:41)
- Discussion Forums
- » Help with Scripts
-
» How do I use "When I Receive" blocks?