This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-05-13 02:20:31

TorbyFork234
Scratcher
Registered: 2012-03-01
Posts: 1000+

"Broadcast and wait"

I never really got what they do or why it was made to be put in the scratch program. I know what broadcast does, but not the broadcast and wait.

Offline

 

#2 2012-05-13 02:30:07

jontmy00
Scratcher
Registered: 2011-11-28
Posts: 1000+

Re: "Broadcast and wait"

It broadcasts a message, then waits until the receiving script finishes.  wink


FOR ALL THE NEWS ON UPDATES FOR SIMPLISTICRAFT, CLICK HERE.

Offline

 

#3 2012-05-13 02:32:44

TorbyFork234
Scratcher
Registered: 2012-03-01
Posts: 1000+

Re: "Broadcast and wait"

jontmy00 wrote:

It broadcasts a message, then waits until the receiving script finishes.  wink

Then why was it made when it can easily be worked around like this:

when gf clicked
forever
broadcast [blah v]
set [var v] to [0]
wait until <(var)=[1]>
set [broadcast and wait v] to [workedarounded]
when I receive [blah v]
wait (1) secs
set [var v] to [1]

Last edited by TorbyFork234 (2012-05-13 02:33:02)

Offline

 

#4 2012-05-13 02:59:54

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: "Broadcast and wait"

TorbyFork234 wrote:

jontmy00 wrote:

It broadcasts a message, then waits until the receiving script finishes.  wink

Then why was it made when it can easily be worked around like this:

when gf clicked
forever
broadcast [blah v]
set [var v] to [0]
wait until <(var)=[1]>
set [broadcast and wait v] to [workedarounded]
when I receive [blah v]
wait (1) secs
set [var v] to [1]

Because that requires a variable and a bunch of extra blocks. Broadcast and wait has a good number of uses, so it makes sense to make it its own block.


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#5 2012-05-13 04:26:27

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: "Broadcast and wait"

TorbyFork234 wrote:

jontmy00 wrote:

It broadcasts a message, then waits until the receiving script finishes.  wink

Then why was it made when it can easily be worked around like this:

when gf clicked
forever
broadcast [blah v]
set [var v] to [0]
wait until <(var)=[1]>
set [broadcast and wait v] to [workedarounded]
when I receive [blah v]
wait (1) secs
set [var v] to [1]

Why was go to included? Change by? Forever? They can be worked around, but it's not easy.

Offline

 

#6 2012-05-13 11:39:00

ManaUser
Scratcher
Registered: 2009-03-11
Posts: 100+

Re: "Broadcast and wait"

For one thing, if several sprites receive the broadcast and perhaps each react slightly differently, it will wait until they're all done. You could still do that without it of course, but setting it up would be alot of work.

I suspect another reason is that broadcast and wait is the closest thing Scratch currently has to functions or subroutines in most programing languages.


http://i.imgur.com/SPYSM.gif http://i.imgur.com/t9k1Z.gif http://i.imgur.com/OwYVa.gif http://i.imgur.com/0qlZq.gif

Offline

 

#7 2012-05-13 14:00:17

EzekielE
Scratcher
Registered: 2010-09-26
Posts: 100+

Re: "Broadcast and wait"

In my most recent game, "Minecraft* (for Scratch)", I have some scripts that I wish to function as if the blocks were in the main script, but I want to be able to call it again and again without duplicating the script. However because the sub-script takes a few seconds to execute, broadcast and wait prevents the two scripts from interfering.

when gf clicked
broadcast [subscript v] and wait
broadcast [subscript v] and wait

*Yes Mojang, that is breaking the MINECRAFT NAME, BRAND AND ASSETS USAGE GUIDELINES. If you care, contact me  big_smile


http://mag.racked.eu/cimage/i2260/Achievement++get%21/Find+a+Disk/mca.pnghttp://ezekielelin.com/1x1Gif/image.php

Offline

 

Board footer