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

#1 2012-03-15 21:13:07

itsmomito
Scratcher
Registered: 2008-03-28
Posts: 100+

Receive Variable

Hi, Currently you can't drag a variable into the receive block. It would be very useful if you could. For Example: I was creating a mesh between many users that relies on broadcasts. I can broadcast a variable, but I can't receive it. I have to define it myself. Thanks, just a suggestion!

Offline

 

#2 2012-03-15 21:26:23

joletole
Scratcher
Registered: 2011-02-20
Posts: 1000+

Re: Receive Variable

The when I receive button is only used for broadcasting.

Offline

 

#3 2012-03-15 21:36:10

CheeseMunchy
Scratcher
Registered: 2008-10-13
Posts: 1000+

Re: Receive Variable

You can't?
Hmm, weird.
Support!


6418,

Offline

 

#4 2012-03-15 21:48:49

stevetheipad
Scratcher
Registered: 2011-08-06
Posts: 1000+

Re: Receive Variable

Hmm....to me, there is a totally different use for the variable and broadcast tools. Variables are like storage and broadcasts are like starters. So, "receiving" a variable doesn't make sense to me, as how is it received? Once it's changed from 0?

And why is this beneficial, versus just doing

wait until (variable 1) = (activate) 
Broadcast (do something)
?


http://i.imgur.com/0x8ia.jpg
gone

Offline

 

#5 2012-03-15 22:07:40

nickbrickmaster
Scratcher
Registered: 2010-02-02
Posts: 500+

Re: Receive Variable

He means changing the value of the dropdown broadcast so you can put in a variable, so it's

when I receive [(x)]
^supposed to be
(x)
instead of
when I receive [1 v]

Last edited by nickbrickmaster (2012-03-15 22:09:06)


Ask me what I'm doing, wait an hour than roll a die, if it's 4-6, I'm playing Skyrim, if it's 1, I'm eating, if it's 2-3 I'm programming.
Steam: nickbrickmaster | RotMG: PwnThemAll | Minecraft: nickbrickmaster | League Of Legends: BaneOfTitans

Offline

 

#6 2012-03-15 22:48:21

stevetheipad
Scratcher
Registered: 2011-08-06
Posts: 1000+

Re: Receive Variable

nickbrickmaster wrote:

He means changing the value of the dropdown broadcast so you can put in a variable, so it's

when I receive [(x)]
^supposed to be
(x)
instead of
when I receive [1 v]

Yeah, I understand that.


http://i.imgur.com/0x8ia.jpg
gone

Offline

 

#7 2012-03-15 23:23:42

itsmomito
Scratcher
Registered: 2008-03-28
Posts: 100+

Re: Receive Variable

Well, I was trying to create a chat program that allows an infinite amount of users to join. The chat user connects through the main program by broadcasting "Add User". When the host receives the broadcast, the var # of already connected users is incremented by 1. The main program also adds a timer to a list. The reason for the timer is to detect when a user disconnects from the main host and it works by each individual chat user broadcasting their user# which was obtained during the "Add User" broadcast from the # of users var at that time. When the main program receives that user#, which I must name and create in the broadcast individually, because I can't insert a variable into the "When I Receive" block, the number is set back to 20. If the number reaches 0, the user disconnects and all user #s are shifted to match the disconnection. Sorry for the trouble, now I realize that it wouldn't work If i put a variable into the when I Receive box. I would have to clone a sprite (Or script if I could) when I receive "Add User" and the sprite would have to create a new broadcast. But this can't be done without a variable placed into the "When I receive" block that would have to be cloned with each added user and changed. It's all a little confusing, and I don't have much programming background, but I got everything to work except for the ability to host infinite amounts of chat users. I currently have to create each "When I Receive" block, which i've only made 10 of so far. This is probably not the most efficient way, but it worked perfectly with a lot of users connected. If the sprite cloning is added to scratch 2.0. I think adding this would be useful.

Last edited by itsmomito (2012-03-15 23:26:29)

Offline

 

#8 2012-03-16 05:46:44

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

Re: Receive Variable

I could think of times that I'd like to put a reporter in that slot.

when I receive (variable)
when I receive (x position)
when I receive (join [action ](pick random (1) to (3)))

Last edited by scimonster (2012-03-16 05:46:59)

Offline

 

#9 2012-03-16 09:21:45

joletole
Scratcher
Registered: 2011-02-20
Posts: 1000+

Re: Receive Variable

stevetheipad wrote:

Hmm....to me, there is a totally different use for the variable and broadcast tools. Variables are like storage and broadcasts are like starters. So, "receiving" a variable doesn't make sense to me, as how is it received? Once it's changed from 0?

And why is this beneficial, versus just doing

wait until <(variable 1) = (activate)> 
Broadcast (do something)
?

Fixed it a bit.

Offline

 

#10 2012-03-16 12:22:41

itsmomito
Scratcher
Registered: 2008-03-28
Posts: 100+

Re: Receive Variable

Yeah i agree with scimonster.

Offline

 

#11 2012-03-16 14:15:35

turkey3
Scratcher
Registered: 2011-12-04
Posts: 500+

Re: Receive Variable

joletole wrote:

stevetheipad wrote:

Hmm....to me, there is a totally different use for the variable and broadcast tools. Variables are like storage and broadcasts are like starters. So, "receiving" a variable doesn't make sense to me, as how is it received? Once it's changed from 0?

And why is this beneficial, versus just doing

wait until <(variable 1) = (activate)> 
Broadcast (do something)
?

Fixed it a bit.

This is basically the same thing as broadcasting a variable.

Offline

 

Board footer