Discuss Scratch

michaeljackson1365
Scratcher
1000+ posts

"Repeat for ___ secs" blocks

no support: there are a bunch of ways to work around this suggestion
lapisi
Scratcher
1000+ posts

"Repeat for ___ secs" blocks

michaeljackson1365 wrote:

(#201)
no support: there are a bunch of ways to work around this suggestion
but are they easy to figure out or do they require a lot of effort that shouldn't be necessary?
Toodchop
Scratcher
100+ posts

"Repeat for ___ secs" blocks

Semi-Support: It can be useful, but there's an easy workaround for it.

reset timer
repeat until <(timer) = []>

end

Last edited by Toodchop (Aug. 2, 2025 13:50:44)

jeffnp
Scratcher
100+ posts

"Repeat for ___ secs" blocks

Scratch runs at 30 fps, so couldn't you just do

repeat ((seconds) * (30))

end
Haycat2009
Scratcher
500+ posts

"Repeat for ___ secs" blocks

You mentioned that there are many workarounds. But there is only one timer. SO if a project needs more than one of these, its in trouble.
CharPikMar
Scratcher
100+ posts

"Repeat for ___ secs" blocks

bump
TimothyLawyer
Scratcher
1000+ posts

"Repeat for ___ secs" blocks

You can make multiple timers.
cookedasparagus8
Scratcher
1000+ posts

"Repeat for ___ secs" blocks

TimothyLawyer wrote:

You can make multiple timers.
when green flag clicked
set [Initial Time v] to (days since 2000 :: sensing)
forever {
set [Timer2 v] to ((days since 2000 :: sensing) - (Inital Time :: variables) :: operators)
} @loopArrow :: control cap
Haycat2009
Scratcher
500+ posts

"Repeat for ___ secs" blocks

Support. The workaround is easy, but reseting the timer interferes with other parts of the project that may require it.
cookedasparagus8
Scratcher
1000+ posts

"Repeat for ___ secs" blocks

Haycat2009 wrote:

Support. The workaround is easy, but reseting the timer interferes with other parts of the project that may require it.
Did you not read the post above you? Can't be talking lol

cookedasparagus8 wrote:

TimothyLawyer wrote:

You can make multiple timers.
when green flag clicked
set [Initial Time v] to (days since 2000 :: sensing)
forever {
set [Timer2 v] to ((days since 2000 :: sensing) - (Inital Time :: variables) :: operators)
} @loopArrow :: control cap
_Paymer
Scratcher
500+ posts

"Repeat for ___ secs" blocks

No support, not much purpose and easy to workaround
CodeComet6161
Scratcher
1000+ posts

"Repeat for ___ secs" blocks

_Paymer wrote:

No support, not much purpose and easy to workaround
repeat for [] secs{
broadcast [message1 v]
}@loopArrow::control
Very useful.
And having an easy workaround is not a reason to not support it.

CodeComet6161 wrote:

cookedasparagus8 wrote:

If you want to use this block right now, literally just search up hacked blocks. Also, this can be easily recreated with a variable and a repeat control block. Mixed support (this isn't a necropost, as it has not officially been implemented.)
With that reasoning, we should remove the
forever

end
block, we just use
repeat ((1) / (0))

end
Source
_nix
Scratcher
1000+ posts

"Repeat for ___ secs" blocks

CodeComet6161 wrote:

_Paymer wrote:

No support, not much purpose and easy to workaround
repeat for [] secs{
broadcast [message1 v]
}@loopArrow::control
Very useful.
And having an easy workaround is not a reason to not support it.
Watch out, though! That script actually usually won't work. The “broadcast” block doesn't actually take any time, so it's going to keep sending out the broadcast OVER AND OVER, with only one frame in between. That means whoever receives the message (the “when I receive” blocks) will end up RESTARTING over and over, because that's what happens when you receive a broadcast-message that's you're already busy processing.

You need to do this instead:

repeat for () seconds {
broadcast [message1 v] and wait
} :: control loop

But then you have the same questions as usual. What happens if you “repeat for 3 seconds” but the receiving script takes longer than 3 seconds? Does the “repeat for…” block immediately quit out, but permit corresponding “when I receive” to keep doing their own thing, on their own time? Or should it cancel out those “when I receive” scripts, too?
purplebunny63
Scratcher
1000+ posts

"Repeat for ___ secs" blocks

cobraguy wrote:

Adding on to @jh1234I's answer, you would want to reset the timer before using the repeat until block.

reset timer
repeat until <(timer) = [?]>

end

It's because the timer automatically starts on the launch of the program, and there is no way to stop it.

  • G
  • O
  • O
  • D

  • I
  • D
  • E
  • A
_Coolguy123_
Scratcher
12 posts

"Repeat for ___ secs" blocks

Haycat2009 wrote:

Support. The workaround is easy, but reseting the timer interferes with other parts of the project that may require it.
I agree. Support for the exact same reason.
KoelDaBird
Scratcher
3 posts

"Repeat for ___ secs" blocks

cobraguy wrote:

Adding on to @jh1234I's answer, you would want to reset the timer before using the repeat until block.

reset timer
repeat until <(timer) = [?]>
do stuff
end

It's because the timer automatically starts on the launch of the program, and there is no way to stop it.
It won't work if there is a sprite using the forever reset timer block
skansgames
Scratcher
2 posts

"Repeat for ___ secs" blocks

cobraguy wrote:

Adding on to @jh1234I's answer, you would want to reset the timer before using the repeat until block.

reset timer
repeat until <(timer) = [?]>
do stuff
end

It's because the timer automatically starts on the launch of the program, and there is no way to stop it.
Actually, there is NO way to work around it
The repeat until block only checks the condition at the end of the script. If you still believe in your work around, try this in Scratch
reset timer
repeat until <(timer) = [5]>
wait (6) secs
end
If the work around works, it should end after 5 seconds
I totally support this:
repeat for () seconds

end
NutOfCoco
Scratcher
100+ posts

"Repeat for ___ secs" blocks

This would be a really weird block though. It would be unreliable because the framerate isn't always 30, so many applications of a repeat block can't be used. The only good use I could think of for this block is FPS tracker, but other ways I feel are much better.
purplebunny63
Scratcher
1000+ posts

"Repeat for ___ secs" blocks

skansgames wrote:

cobraguy wrote:

Adding on to @jh1234I's answer, you would want to reset the timer before using the repeat until block.

reset timer
repeat until <(timer) = [?]>
do stuff
end

It's because the timer automatically starts on the launch of the program, and there is no way to stop it.
Actually, there is NO way to work around it
The repeat until block only checks the condition at the end of the script. If you still believe in your work around, try this in Scratch
reset timer
repeat until <(timer) = [5]>
wait (6) secs
end
If the work around works, it should end after 5 seconds
I totally support this:
repeat for () seconds {

}::control

Powered by DjangoBB