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

#1 2009-08-01 15:01:27

Mozaz
Scratcher
Registered: 2009-05-19
Posts: 500+

Broadcasting Variables

Hey.

On my latest project I came across something which I think may help a few people in scratch. If you take a broadcast block:
[blocks]
<broadcast[ ]
[/blocks]

Then if you take a variable, you can put the variable inside the broadcast block.

What this block will do is, is broadcast the value of that variable. For example, if the value of a variable was 1, then the broadcast block would broadcast 1.

You then have to take a 'When I recieve [ ]' block and on the scroll down menu, click new... and then type in a value that you would assume the variable would change to. In this case, add '1'

Then, when ever the value of that variable is 1, it will broadcast the message '1' and a script which receives the '1' would then start.

It could be used in a lot of cases. For example, at the moment I am using it in a custom OS I am making, where each program has a value of a variable. For example, the paint editor would be value 1, then calculator would be value 2 etc. When the program changes, a few things need to be done, for example sprites need to be re-positioned. When the program changes, the broadcast block broadcasts the value for the new program and when a script recieves that value, it starts the script.

Hope I explained it clearly  smile


http://i33.tinypic.com/15i5fmp.png

Offline

 

#2 2009-08-02 04:48:15

filo5
Scratcher
Registered: 2008-01-08
Posts: 1000+

Re: Broadcasting Variables

Helpful, but someone has figured it out before.


Converting my Scratch projects to Python!

Offline

 

#3 2009-08-03 05:15:11

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Broadcasting Variables

Great explanation!  You can also broadcast variable values that are words and letters, not just numbers.  That might make it easier to understand the scripts...you can have "When I Receive Paint" to run the paint program for instance  smile


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#4 2009-08-03 06:29:16

Mozaz
Scratcher
Registered: 2009-05-19
Posts: 500+

Re: Broadcasting Variables

Paddle2See wrote:

Great explanation!  You can also broadcast variable values that are words and letters, not just numbers.  That might make it easier to understand the scripts...you can have "When I Receive Paint" to run the paint program for instance  smile

Of course! Nice idea. Forgot that they changed the blocks to support words now. Thanks P2S  smile


http://i33.tinypic.com/15i5fmp.png

Offline

 

#5 2009-08-03 08:38:00

The-Whiz
Scratcher
Registered: 2007-07-09
Posts: 1000+

Re: Broadcasting Variables

Nice idea! I used this in my ScratchText program...

Offline

 

Board footer