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

#1 2011-09-19 15:48:33

SD7
Scratcher
Registered: 2011-09-15
Posts: 100+

How to set variable limit so script stops

Is there a way to set it so that when the count on a certain variable ("Score1" and "Score2" in this case) reach a certain limit, the script stops or another command is given? I'm trying to get my Pong remake to have a score limit, but so far everything I've tried hasn't worked. Thanks for any help.


http://img834.imageshack.us/img834/4411/signaturespacegame2.png

Offline

 

#2 2011-09-19 16:08:14

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: How to set variable limit so script stops

<when green flag clicked>
<forever><if><{  }>=something
<broadcast[ command
<stop script>
<end>


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#3 2011-09-19 17:22:53

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

Re: How to set variable limit so script stops

<when green flag clicked>
<forever>
      <if>  <(  <{  score  }>  <>>  6  )>
            <broadcast[  stop game  ]>
            <stop script>
      <end>
      Rest of Script Goes Here
<end>


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

Offline

 

#4 2011-09-19 18:55:20

SD7
Scratcher
Registered: 2011-09-15
Posts: 100+

Re: How to set variable limit so script stops

Ok, it needed a broadcast thing. That's basically what I set up just without the broadcast part


http://img834.imageshack.us/img834/4411/signaturespacegame2.png

Offline

 

#5 2011-09-19 22:04:07

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: How to set variable limit so script stops

MoreGamesNow wrote:

<when green flag clicked>
<forever>
      <if>  <(  <{  score  }>  <>>  6  )>
            <broadcast[  stop game  ]>
            <stop script>
      <end>
      Rest of Script Goes Here
<end>

You actually need an if-else, not an if I think.


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#6 2011-09-19 22:47:11

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

Re: How to set variable limit so script stops

No, because if it is true, it terminates the script beneath it anyway.  If it isn't true, the script beneath it runs.


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

Offline

 

Board footer