Discuss Scratch

sccar3
Scratcher
100+ posts

"Repeat for () secondss" Block

I think there should be a C block that repeats the scripts inside for a set number of seconds.
It would be like:
repeat ()

end
But it would say “repeat for () seconds”.

There are workarounds for this, such as:
reset timer
repeat until <(timer) = []>
stuff // category=grey
end
But that won't work if you need to use the timer for other things.

10-year Scratch veteran. Fight me.
AonymousGuy
Scratcher
1000+ posts

"Repeat for () secondss" Block

sccar3 wrote:

reset timer
repeat until <(timer) = []>
stuff // category=grey
end
But that won't work if you need to use the timer for other things.
set [oldtime v] to (timer)
repeat until <((timer) - (oldtime)) = [Your value here...]
...
end

Last edited by AonymousGuy (Dec. 25, 2013 03:40:00)

Chainmanner
Scratcher
100+ posts

"Repeat for () secondss" Block

Or, you can use:
repeat (time-in-seconds)
some random stuff
wait (1) secs
end

Last edited by Chainmanner (Dec. 25, 2013 09:06:25)

AonymousGuy
Scratcher
1000+ posts

"Repeat for () secondss" Block

Chainmanner wrote:

Or, you can use:
repeat (time-in-seconds)
some random stuff
wait (1) secs
end
Not if you want 0.5 seconds. Or if you want it to run without stopping.

Last edited by AonymousGuy (Dec. 25, 2013 16:10:02)

1234abcdcba4321
Scratcher
1000+ posts

"Repeat for () secondss" Block

repeat ((time you want) / (time it takes for one loop))
...
end

So if you want 10 secs, and you time it to take 0.2 secs, you would put 50.

I'd highly appreciate it if you were to follow me. Don't forget to go to my profile.
All of my programming suggestions <— You should really get the suggestions move back to the suggestions forum!
Five hundred posts! I never expected to get up there… In only 2-3 months.
Does anyone know what a signature is? I mean, I've already seen 6-7 people get confused.
scimonster
Scratcher
1000+ posts

"Repeat for () secondss" Block

1234abcdcba4321 wrote:

repeat ((time you want) / (time it takes for one loop))
...
end

So if you want 10 secs, and you time it to take 0.2 secs, you would put 50.
Except that you can't predict exactly how long a loop will take for everyone.

The timer method is best.

Retired Community Moderator
BTW, i run Google Chrome 41.0.2272.101 on a Linux system - Ubuntu 14.04. NEW: iPad 4th gen. w/retina.

418 I'm a teapot (original - to be read by bored computer geeks)
THE GAME (you just lost)
; THE SEMICOLON LIVES ON IN OUR SIGS
mathfreak231
Scratcher
1000+ posts

"Repeat for () secondss" Block

Repeat for a Set Amount of Time
The methods listed here are accurate enough.

i have grown as a person. and ive grown, literally. none of my posts from before 2022 represent me accurately.

Powered by DjangoBB