This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.
  • Index
  •  » Advanced Topics
  •  » does it cause more lag to use a repeat until or a forever with a stop?

#1 2011-05-12 16:29:41

estorken
Scratcher
Registered: 2010-04-01
Posts: 41

does it cause more lag to use a repeat until or a forever with a stop?

I've always used repeat until's but I've noticed people using forevers with an if (conditions){stop script}. which one actually causes less lag? or is there a different advantage to one or the other (not counting the fact that you can add scripts to the bottom of a repeat until)

Last edited by estorken (2011-05-12 16:30:38)


http://i56.tinypic.com/esqpma.gif

Offline

 

#2 2011-05-12 16:34:37

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: does it cause more lag to use a repeat until or a forever with a stop?

Well, the advantage you mentioned is only valid for 1s1s projects, as you can easily stick in a broadcast right before the stop script.

I think that the repeat until should cause less lag (of a couple milliseconds) because it's a block less, even if the actions performed are exactly the same (at each loop, check the condition).

The only real advantage of using the IF block is that you can stick it in wherever you need, whereas with the repeat until you have no choice over that (checks it before each loop).

So it really depends on what your purpose is.
Less lag: Repeat until
More customize-ability: IF clause

Offline

 

#3 2011-05-12 17:07:05

estorken
Scratcher
Registered: 2010-04-01
Posts: 41

Re: does it cause more lag to use a repeat until or a forever with a stop?

thanks, that what i thought, but i wasn't quite sure


http://i56.tinypic.com/esqpma.gif

Offline

 

#4 2011-05-12 17:15:32

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: does it cause more lag to use a repeat until or a forever with a stop?

I use the repeat until a lot coupled with a variable called "place". Then, when place applies to that script. This way when a "place" is left, the scripts can stop and they don't slow the other scripts down when they're really not needed. It does mean broadcasting a lot though.


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#5 2011-05-12 20:45:56

gbear605
Scratcher
Registered: 2008-03-06
Posts: 1000+

Re: does it cause more lag to use a repeat until or a forever with a stop?

LS97 wrote:

Well, the advantage you mentioned is only valid for 1s1s projects, as you can easily stick in a broadcast right before the stop script.

I think that the repeat until should cause less lag (of a couple milliseconds) because it's a block less, even if the actions performed are exactly the same (at each loop, check the condition).

The only real advantage of using the IF block is that you can stick it in wherever you need, whereas with the repeat until you have no choice over that (checks it before each loop).

So it really depends on what your purpose is.
Less lag: Repeat until
More customize-ability: IF clause

To be exact, it would save 10 millisecs (as that is how long a block takes to run.)


Yeah, I'm mostly inactive.  I check in once in a while though.  If you want to contact me, I have a contact form at my website, http://escratch.org

Offline

 
  • Index
  •  » Advanced Topics
  •  » does it cause more lag to use a repeat until or a forever with a stop?

Board footer