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

#1 2010-11-24 22:58:22

WCoaster
New Scratcher
Registered: 2010-11-21
Posts: 7

How do I recieve a variable?

It is possibla to broadcast a variable but I can not see how to recieve one.

Is it possible?

Offline

 

#2 2010-11-24 23:02:04

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: How do I recieve a variable?

Yes, it is.
Example:
[blocks]
<when[ a ]key pressed>
<set{ score }to( 1 )
<broadcast[ <{ score }> ]

<when[ b ]key pressed>
<set{ score }to( 2 )
<broadcast[ <{ score }> ]

<when I receive[ 1 ]
<forever>
<move( 5 )steps>
<if on edge, bounce>
<end>

<when I receive[ 2 ]
<forever>
<move( 7 )steps>
<if on edge, bounce>
<end>

[/blocks]You just cannot use when I receive "variable" because... just because it doesn't work...

Offline

 

#3 2010-11-24 23:04:36

WCoaster
New Scratcher
Registered: 2010-11-21
Posts: 7

Re: How do I recieve a variable?

Justy because the scratch block is not programed to recieve a variable?
That is my fear any way.

Offline

 

#4 2010-11-25 06:17:12

rubiks_cube_guy238
Scratcher
Registered: 2009-07-02
Posts: 100+

Re: How do I recieve a variable?

If you don't take kayybee's method into acount, here is the answer:
You don't.
Not right now, at least. I'm hoping they will include that feature in 2.0.


The glass is never half full nor half empty; it is twice as large as it needs to be.

Offline

 

#5 2010-11-25 06:28:27

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

Re: How do I recieve a variable?

Just Make a new "When I receive" hat block with the value of the variable.  Then, when you broadcast the variable with that value, the hat block will be activated.


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

Offline

 

#6 2010-11-27 01:15:40

wei2912
Scratcher
Registered: 2010-05-09
Posts: 100+

Re: How do I recieve a variable?

WCoaster wrote:

Justy because the scratch block is not programed to recieve a variable?
That is my fear any way.

It can. But it can only recieve those you made.

For example:

when green flag clicked
set broadcast to random 1 to 9
broadcast broadcast

you will have to make seperate number for each (1 to 9).


Waiting for Scratch 2.0...

Offline

 

#7 2010-11-27 02:52:33

WCoaster
New Scratcher
Registered: 2010-11-21
Posts: 7

Re: How do I recieve a variable?

wei2912 wrote:

It can. But it can only recieve those you made.

For example:

when green flag clicked
set broadcast to random 1 to 9
broadcast broadcast

you will have to make seperate number for each (1 to 9).

Thanks wei, The broadcast a variable part I got but it is the recieve part that does not exist according to rubiks post.

I think I will research Paddles option.

Anyone have a good resource for programming blocks?

Thanks

Offline

 

Board footer