Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » When and how to use the "broadcast" block and the "when I receive" block
- duchan
-
1 post
When and how to use the "broadcast" block and the "when I receive" block
I'm working on a project in Scratch and I would like to use the “broadcast” and “when I receive” blocks in it. The timing of the conversation between the sprites (and when they move) is all messed up and out of order when I use them. Previously, I used the “when___key pressed” block, but it's very confusing. How do I use these blocks and when? Also, in the space where you can write the message you want the sprite to receive, does it matter what you type there as long as it makes sense to you? Thanks in advance! 

- 1002873
-
25 posts
When and how to use the "broadcast" block and the "when I receive" block
to answer your title's question:
Broadcasting blocks can be used as a trigger that can change something you couldn't do in just one sprite.
In your case, making the other person talk.
So, let's say after something happens (your character talks), a broadcast is sent, called “message1”.
If you go to another sprite, and put in “when i recieve message1” and, say, put a say block after that, it should
be like:
SPRITE1: Hi!
(Sprite1 broadcasts a signal.)
(Sprite2 recieves the signal, and decides what to do when it recieves it. In this case, reply.)
SPRITE2: Hello! How are you?
And no, it does not matter what you type in. It's just the name of the signal, so that multiple signals can be separated and identified easily.
Broadcasting blocks can be used as a trigger that can change something you couldn't do in just one sprite.
In your case, making the other person talk.
So, let's say after something happens (your character talks), a broadcast is sent, called “message1”.
If you go to another sprite, and put in “when i recieve message1” and, say, put a say block after that, it should
be like:
SPRITE1: Hi!
(Sprite1 broadcasts a signal.)
(Sprite2 recieves the signal, and decides what to do when it recieves it. In this case, reply.)
SPRITE2: Hello! How are you?
And no, it does not matter what you type in. It's just the name of the signal, so that multiple signals can be separated and identified easily.
- drmcw
-
1000+ posts
When and how to use the "broadcast" block and the "when I receive" block
Remember that broadcast sends the message but then continues to run its script as well. If you want the broadcast script to wait until all the broadcast scripts finish running then use broadcast and wait. If you are using broadcast to control speech between sprites then I expect you will need to use broadcast and wait.
- Locomule
-
1000+ posts
When and how to use the "broadcast" block and the "when I receive" block
Also, there is a slight delay when using a broadcast and wait. If it is too long for your project, try using a non-wait style broadcast and a seperate variable.
In your broadcast script, set the variable to 0 just before the broadcast block. Just after the broadcast block, put a “wait until variable equals 1” block. Now go to the script that receives that broadcast and at the end of it set your variable to 1.
In your broadcast script, set the variable to 0 just before the broadcast block. Just after the broadcast block, put a “wait until variable equals 1” block. Now go to the script that receives that broadcast and at the end of it set your variable to 1.
- scubajerry
-
1000+ posts
When and how to use the "broadcast" block and the "when I receive" block
Also, there is a slight delay when using a broadcast and wait.
What is your source for this. I can't make a test that shows this.
- scimonster
-
1000+ posts
When and how to use the "broadcast" block and the "when I receive" block
I like to compare Scratch's broadcasts to radio. When a sprite broadcasts something using the broadcast () block, it's analogous to a radio message – it's sent out everywhere, but only accessible to people listening for it. The when I receive () block is like a home radio – you tune it to listen on a specific “station”, i.e. broadcast.
Broadcast and wait is a little more complex – here, it waits to continue with the original script until after all when i receive scripts have ended.
Broadcast and wait is a little more complex – here, it waits to continue with the original script until after all when i receive scripts have ended.
- LoopyS
-
100+ posts
When and how to use the "broadcast" block and the "when I receive" block
When and how to use Broadcast and Receive Blocks.
In Sprite 1 put,
In Sprite 2 put,
And so on…
I hope this helped!
P.S. If you have any more questions, you can post them HERE, and get a detailed answer from me.
In Sprite 1 put,
In Sprite 2 put,
And so on…
I hope this helped!
P.S. If you have any more questions, you can post them HERE, and get a detailed answer from me.
Last edited by LoopyS (Oct. 15, 2013 07:05:16)
- Locomule
-
1000+ posts
When and how to use the "broadcast" block and the "when I receive" block
My source? This is common Scratch kowledge. I just tested it and the trigger variable method was about twice as fast as using Broadcast and Wait. In small projects, this lag isn't often noticable but in a complex project, it can be pretty bad.
- scubajerry
-
1000+ posts
When and how to use the "broadcast" block and the "when I receive" block
can you share your project where you tested this? It doesn't make sense to me, and I don't know I how to test it. I would like to understand it. My source? This is common Scratch kowledge. I just tested it and the trigger variable method was about twice as fast as using Broadcast and Wait. In small projects, this lag isn't often noticable but in a complex project, it can be pretty bad.
- drmcw
-
1000+ posts
When and how to use the "broadcast" block and the "when I receive" block
That method does not work the same as a broadcast and wait though. If another script broadcasts the same message then a broadcast and wait will unblock. This method will only unblock when the broadcast resets the variable. Could be useful but is not a replacement for broadcast and wait. Also, there is a slight delay when using a broadcast and wait. If it is too long for your project, try using a non-wait style broadcast and a seperate variable.
In your broadcast script, set the variable to 0 just before the broadcast block. Just after the broadcast block, put a “wait until variable equals 1” block. Now go to the script that receives that broadcast and at the end of it set your variable to 1.
- zamorta4148
-
5 posts
When and how to use the "broadcast" block and the "when I receive" block
w
- GJbusyScratching
-
20 posts
When and how to use the "broadcast" block and the "when I receive" block
hey so i am trying to use a when i recive and a when this sprite is clicked anyone suggestions on a alternative?
- roar_forever
-
4 posts
When and how to use the "broadcast" block and the "when I receive" block
Hey when I'm making a game, I wish there was a “when I receive” block that I didn't have to put on the top of the script so I could send a broadcast to the middle of a script. Anyone know an alternative? 

- medians
-
1000+ posts
When and how to use the "broadcast" block and the "when I receive" block
Please create a new topic for this instead of Hey when I'm making a game, I wish there was a “when I receive” block that I didn't have to put on the top of the script so I could send a broadcast to the middle of a script. Anyone know an alternative? necroposting.
And explain what you mean by “to the middle of a script”, you don’t have to put the “broadcast [ v]”/“broadcast [ v] and wait” block at the top of the script.
Last edited by medians (April 26, 2023 23:19:45)
- 09878901234321
-
500+ posts
When and how to use the "broadcast" block and the "when I receive" block
I made a project to show the delay:Also, there is a slight delay when using a broadcast and wait.
What is your source for this. I can't make a test that shows this.
https://scratch.mit.edu/projects/841768940/
- Discussion Forums
- » Help with Scripts
-
» When and how to use the "broadcast" block and the "when I receive" block