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

#1 2013-04-21 15:44:00

andrewguy
New Scratcher
Registered: 2013-04-16
Posts: 4

How to make the "forever if" control really last forever?

When I say: forever if timer>10, go to X0, Y0, it only works the first time. Then whenever the timer reaches >10 the second time, nothing happens. I eliminated all the STOP ALL controls, so the forever if is still working, but the script I gave the forever if never works.

Offline

 

#2 2013-04-21 18:10:21

Sausagefanclub
Scratcher
Registered: 2011-08-31
Posts: 500+

Re: How to make the "forever if" control really last forever?

Are you using a block that resets the timer every time you start the project?
This arrangement might work:

when gf clicked
reset timer
forever if <(timer) > [10]>
  go to x: (0) y: (0)
end
If not, perhaps you can post a picture of your scripts.


http://sausagepages1185.weebly.com/uploads/1/4/1/5/14153465/446452.png?525

Offline

 

#3 2013-04-21 20:04:59

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: How to make the "forever if" control really last forever?

andrewguy wrote:

When I say: forever if timer>10, go to X0, Y0, it only works the first time. Then whenever the timer reaches >10 the second time, nothing happens. I eliminated all the STOP ALL controls, so the forever if is still working, but the script I gave the forever if never works.

Basically, the forever if loop is broken once the condition is broken. To make it last forever,  which you shouldn't probably do that, but if that's what you want, do this:

when gf clicked
forever
if < condition >
do stuff...
end
end
Regards,

CAA14

Offline

 

#4 2013-04-21 21:34:45

Hyperbola
Scratcher
Registered: 2013-03-15
Posts: 100+

Re: How to make the "forever if" control really last forever?

CAA14 wrote:

Basically, the forever if loop is broken once the condition is broken.

Erm.. No it doesn't? It's just like forever(if(whatever)).


Tip of the whatever: Don't post in threads older than 2 weeks unless your post will actually be useful.
It's the last day of 1.4! *cries* (quote from NeilWest, rest by me) by the time you read this it probably will be 2.0  sad

Offline

 

#5 2013-04-21 21:54:02

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: How to make the "forever if" control really last forever?

Hyperbola wrote:

CAA14 wrote:

Basically, the forever if loop is broken once the condition is broken.

Erm.. No it doesn't? It's just like forever(if(whatever)).

Not really. Basically, if it's an "forever if" loop, it will go on forever if the condition is true,
But an if nested in an forever loop will still check the condition forever, but it won't do anything if the condition is false.


See?

when gf clicked
forever
if <touching? [player v]>
switch to costume [dead v]
end
end
As opposed to:


when gf clicked
forever if <touching? [player v]>
switch to costume [dead v]
end
This would only check the condition once, and then it would break if the player wasn't touching whatever this sprite is.

Regards,

CAA14

Offline

 

Board footer