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

#1 2011-10-10 21:03:59

Bookworm300
Scratcher
Registered: 2011-06-04
Posts: 28

Help with script.

I need a script where an object keeps on doing something until he receives a broadcast. Is there any way to do that?

Offline

 

#2 2011-10-10 23:41:08

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Help with script.

Bookworm300 wrote:

I need a script where an object keeps on doing something until he receives a broadcast. Is there any way to do that?

Depends...if when he receives it, everything stops, then you just need a script that stops all.

Besides that, you'll probably have to use a variable that gets set to a value when that event that would broadcast happens.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#3 2011-10-10 23:55:44

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

Re: Help with script.

Well, what you would want is the fictional http://wiki.scratch.mit.edu/images/%28%29_Received%3F.png block.
Click on the image for a workaround which you can use.  smile

Offline

 

#4 2011-10-11 07:33:24

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Help with script.

Or something like this:

<when I receive[  something  ]>
<set{  continue?  }to(  1  )
<repeat until><(  <{  continue?  }>  <=>  0  )>

      Script

<end>


Then, to stop it, just set "continue?" to 0 instead of broadcasting "StopScript".

Last edited by MoreGamesNow (2011-10-11 07:33:40)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#5 2011-10-11 09:51:45

rojasscratches
Scratcher
Registered: 2011-06-01
Posts: 59

Re: Help with script.

I've had the same trouble as you and figured out how to fix it. instead of using a broadcast, use a variable
<when green flag clicked>
<forever>
<repeat until><(<{ name of variable }><=>1
<move( 10 )steps>
<end>
<end>

and instead of telling it to broadcast now you need to tell it to always set your variable to 0 except when you want it to stop doing something

Last edited by rojasscratches (2011-10-11 09:57:00)


smile   neutral   sad   big_smile   yikes   wink   hmm   tongue   lol   mad   roll   cool  cool  Scratch Home Page  cool

Offline

 

Board footer