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

#1 2008-04-23 06:33:24

hp001
Scratcher
Registered: 2008-04-20
Posts: 4

Problem...forever if doesnt stop if the condition is met

i have a script
[blocks]
<when green flag clicked>
<forever if><touching[ mouse pointer
<broadcast[ to field
<wait until>  <not> <touching[ mouse pointer >>
<forever if> <( <{ Arrow Clicked  }>  <=> 1 >
<set{ Arrow Clicked  }to( 0 )
<stop script>
[/blocks]

yet in an identical script for another sprite, when the variable changes it does not stop the script

HELP

Last edited by hp001 (2008-04-23 06:33:53)

Offline

 

#2 2008-04-23 06:42:01

Jacobo
Scratcher
Registered: 2007-06-15
Posts: 100+

Re: Problem...forever if doesnt stop if the condition is met

hmmm. Are you sure you made the script correctly. I made two sprites with that exact script and they both stopped perfectly.

Last edited by Jacobo (2008-04-23 06:42:13)


"It's like deja vu all over again"
-Yogi Berra

Offline

 

#3 2008-04-23 07:01:05

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: Problem...forever if doesnt stop if the condition is met

The forever if loop will *always* run, each time checking if the condition is met. It will never stop. It's not a 'forever until ... ', or a 'while' loop.


Jens Mönig

Offline

 

#4 2008-04-23 14:32:50

Jacobo
Scratcher
Registered: 2007-06-15
Posts: 100+

Re: Problem...forever if doesnt stop if the condition is met

Instead of
<forever if><( <{ arrow clicked }> <=> 1 )>
<set{ arrow clicked }to( 0
<stop script>
<end>

you could do

<repeat until><( <{ arrow clicked }> <=> 0 )>
<if>> <( <{ arrow clicked }> <=> 1 )>
<set{ arrow clicked }to( 0
<stop script>
<end>


"It's like deja vu all over again"
-Yogi Berra

Offline

 

#5 2008-04-24 03:40:21

hp001
Scratcher
Registered: 2008-04-20
Posts: 4

Re: Problem...forever if doesnt stop if the condition is met

yeah thats all good but the thing is there are 2 similar scripts running simultaniously. when the condition is met one stops but the other 1 continues. it happens to be the point where
[blocks]
<forever if><( <{ Arrow Clicked   }> <=> 1 )>
<set{ Arrow Clicked   }to( 0
<stop script>
[/blocks]

and then one script stops when that initial condition is met but the other 1 continues. Even though there are 2 similar scripts running, the above part is common to both scripts so when i move on and place my mouse on the other sprites original location before it was told to hide, it broadcasts the same message as if it was still there and that changes the way the game works.

Last edited by hp001 (2008-04-24 03:45:47)

Offline

 

#6 2008-04-24 16:04:34

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Problem...forever if doesnt stop if the condition is met

yeah do the repeat until thing that Jacobo mentioned. What the forever if thing is I think always runs, but only starts if the condition it true

Offline

 

Board footer