broadcast () and wait

Broadcast () and wait

The broadcast () and wait block is a stack block in the Events category that broadcasts a message, but then waits for all sprites to finish running the code associated with the message. It originates from Scratch. The default selected broadcast is the same as the broadcast () block (i.e. the last created broadcast).

It can be used to only do animations or speech after another sprite has finished:

say [Hello there, children!]
speak [Hello there, children!]
broadcast (children speak v) and wait
say [How's it going?]
speak [How's it going?]

Workaround

This block can be worked around by using a variable or a list to signify when the message is done in a sprite, and using the broadcast () block:

broadcast (name v)
set [broadcast complete? v] to [false]
wait until <(broadcast complete?)::operators>
code::grey
when I receive [name v]
code::grey
set [broadcast complete? v] to [true]