Discuss Scratch

red_king_cyclops
Scratcher
500+ posts

Idea for new block: repeat for () seconds

The "repeat for blank seconds' block would look like this (but as an actual C-block):

repeat for () seconds ::control

end

It would work the same as the repeat block, but instead of repeating a given amount of times it constantly repeats for a given time (in seconds).

If this is a duplicate, too bad. There isn't a proper and official forum search that will work for finding duplicates and I have no idea to find them anyway.

If there is a workaround, someone already made an argument against workarounds somewhere in this forum.

Last edited by red_king_cyclops (Nov. 26, 2017 15:36:51)

Charles12310
Scratcher
1000+ posts

Idea for new block: repeat for () seconds

No support because you could break this block by adding a script that runs for more than the said seconds.

If you don't understand, this is what I mean:

repeat for (5) secs {
wait (10) secs
} :: control

You could see this gets very confusing, and it causes ambiguity. What happens when the 5 seconds are up? Does the script still go until it ends? Does the script stop in the middle?
TEAMWFS
Scratcher
100+ posts

Idea for new block: repeat for () seconds

repeat until <[timer] = [blah blah blah]>
script here
end
TheUltimatum
Scratcher
1000+ posts

Idea for new block: repeat for () seconds

set [wait v] to [32] // how many seconds you want to wait for.
reset timer
repeat until <<(timer::sensing) > (wait)> or <(timer::sensing) = (wait)>>
say (join (timer::sensing)[ seconds passed in the loop!])
end

This workaround assumes you won't be using the timer elsewhere in your project. A somewhat more complicated workaround can be done to avoid this but I don't have the time to set it up right now.

Last edited by TheUltimatum (Nov. 26, 2017 23:04:12)

Charles12310
Scratcher
1000+ posts

Idea for new block: repeat for () seconds

TheUltimatum wrote:

set [wait v] to [32] // how many seconds you want to wait for.
reset timer
repeat until <<(timer::sensing) > (wait)> or <(timer::sensing) = (wait)>>
say (join (timer::sensing)[ seconds passed in the loop!])
end

This workaround assumes you won't be using the timer elsewhere in your project. A somewhat more complicated workaround can be done to avoid this but I don't have the time to set it up right now.
set [previous timer v] to (timer)
repeat until <((timer) - (previous timer)) > [...]> // insert number
...
end
iforgotmyrandomname
Scratcher
47 posts

Idea for new block: repeat for () seconds

Charles12310 wrote:

No support because you could break this block by adding a script that runs for more than the said seconds.

If you don't understand, this is what I mean:

repeat for (5) secs {
wait (10) secs
} :: control

You could see this gets very confusing, and it causes ambiguity. What happens when the 5 seconds are up? Does the script still go until it ends? Does the script stop in the middle?
This is why I don't support.

red_king_cyclops wrote:

If this is a duplicate, too bad. There isn't a proper and official forum search that will work for finding duplicates and I have no idea to find them anyway.
Although there is no official forum search on Scratch, you can do a Google search with this search term:
site:scratch.mit.edu/discuss/ ReplaceThisWithYourTopic

Last edited by iforgotmyrandomname (Nov. 27, 2017 02:52:03)

_Lillion_
Scratcher
500+ posts

Idea for new block: repeat for () seconds

Sorry but I personally don't get the point of the block as you can simply do:

repeat until <(timer) = [...]>
Script here
end
kenny2scratch
Scratcher
500+ posts

Idea for new block: repeat for () seconds

--Awesome
Scratcher
59 posts

Idea for new block: repeat for () seconds

_Lillion_ wrote:

Sorry but I personally don't get the point of the block as you can simply do:

repeat until <(timer) = [...]>
Script here
end
Agreed. No support, sorry.

Powered by DjangoBB