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

#1 2010-09-12 01:50:58

Shadowed1
Scratcher
Registered: 2010-01-19
Posts: 100+

Using "When I recieve ..." in a script

Well, sometimes you have to use a "When i recieve..." , like in this script:
[blocks]
<when I receive[ anything ]<broadcast[ you win ]
[/blocks]
Well if you could have a second "When I recieve ..." in there, it could be easier. So when i recieve this, wait until i recieve this, then do this. It could help to do a ton of scripting in only a few lines of scripting.
[blocks]
<( PS. Scratch <=> awesome! )>


*Insert some witty, funny or sarcastic comment here*

Offline

 

#2 2010-09-12 04:14:54

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: Using "When I recieve ..." in a script

You could just do this:

[when I receive [broadcast])
[wait until <(variable) = (1)>]
action goes here

If there were a <[broadcast] received?> block, it would sort of work for your suggestion:

[when I receive [broadcast 1])
[wait until <[broadcast 2] received?>]
action goes here

The "When I receive" idea is more of a Hat block - I think the <[ ] received?> Boolean block would fit better.  smile

Last edited by Jonathanpb (2010-09-12 04:15:18)


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#3 2010-09-12 08:18:51

jackrulez
Scratcher
Registered: 2009-08-01
Posts: 1000+

Re: Using "When I recieve ..." in a script

Jonathanpb wrote:

You could just do this:

[when I receive [broadcast])
[wait until <(variable) = (1)>]
action goes here

If there were a <[broadcast] received?> block, it would sort of work for your suggestion:

[when I receive [broadcast 1])
[wait until <[broadcast 2] received?>]
action goes here

The "When I receive" idea is more of a Hat block - I think the <[ ] received?> Boolean block would fit better.  smile

Yeah... Plus, <[ v] received?> just sounds better.


Yawn, another boring text signature. I should really make something better.

Offline

 

#4 2010-09-12 09:49:38

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: Using "When I recieve ..." in a script

Sorry, but I don't think it would really work well. I quote coolstuff from here:

coolstuff wrote:

I don't know how many times I've had to type this, but it WON"T HAPPEN BECAUSE BROADCASTS AREN'T BOOLEAN.

Boolean means the answer is 0 or 1. All of the diamond-shaped blocks are boolean, <a = 1> is boolean because either a is equal to one or a is not equal to one, 1 being if it is equal and 0 being if it isn't.

Thus it's not possible - a broadcast happens instantly, so a script couldn't catch it, and to allow it to catch it you would have to slow the broadcasting process which would be overall bad, as slow as it already is.  hmm


http://i.imgur.com/WBkM2QQ.png

Offline

 

#5 2010-09-12 09:51:17

demosthenes
Retired Community Moderator
Registered: 2008-02-19
Posts: 1000+

Re: Using "When I recieve ..." in a script

Yes Broadcasts are not Boolean. However, a viable block is:
"[Wait Until <Broadcast --> Recieved]"

"Broadcast Recieved" should not be a boolean, however the above blocks allow you do all you want to do and not mess things up.


I've taken a long hiatus, but I still visit sometimes. Give me some time to answer any messages you post on my projects!

Offline

 

#6 2010-09-12 10:03:49

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: Using "When I recieve ..." in a script

demosthenes wrote:

Yes Broadcasts are not Boolean. However, a viable block is:
"[Wait Until <Broadcast --> Recieved]"

"Broadcast Recieved" should not be a boolean, however the above blocks allow you do all you want to do and not mess things up.

But what if you broadcast a message multiple times, such as in a recursion or something similar?


http://i.imgur.com/WBkM2QQ.png

Offline

 

#7 2010-09-12 10:21:28

demosthenes
Retired Community Moderator
Registered: 2008-02-19
Posts: 1000+

Re: Using "When I recieve ..." in a script

Lucario621 wrote:

demosthenes wrote:

Yes Broadcasts are not Boolean. However, a viable block is:
"[Wait Until <Broadcast --> Recieved]"

"Broadcast Recieved" should not be a boolean, however the above blocks allow you do all you want to do and not mess things up.

But what if you broadcast a message multiple times, such as in a recursion or something similar?

Then each time it would be "True" for a fraction of a second, and any current scripts waiting at a "[Wait Until <Broadcast --> Recieved]" would pass on to the next block, otherwise things would remain the same.


I've taken a long hiatus, but I still visit sometimes. Give me some time to answer any messages you post on my projects!

Offline

 

Board footer