Discuss Scratch
- HarmlessOstrich
-
100+ posts
a every () seconds block!
we need an
it would be a C block but i dont know how to make that
it would repeat a code every () seconds
Every () seconds
it would be a C block but i dont know how to make that

- MDCCCLXVII
-
1000+ posts
a every () seconds block!
it would be a C block but i dont know how to make that
every (1) seconds {
} :: control loop
- HarmlessOstrich
-
100+ posts
a every () seconds block!
it would be a C block but i dont know how to make thatevery (1) seconds {
} :: control loop
thx
- fdreerf
-
1000+ posts
a every () seconds block!
A very crude implementation would just be:
and I believe that this would be more accurate:
and if you want to make your limited time on this wretched planet worth it:
forever
...
wait (time ::grey) secs
end
and I believe that this would be more accurate:
forever
if <((timer) mod (time ::grey)) = [0]> then
...
end
end
and if you want to make your limited time on this wretched planet worth it:
forever
if <((((days since 2000) - ([floor v] of (days since 2000))) * (86400)) mod (time ::grey)) = [0]> then
...
end
end
- fdreerf
-
1000+ posts
a every () seconds block!
https://scratch-mit-edu.ezproxyberklee.flo.org/projects/382631312/editorThat's very cool but I don't believe that project has what the suggestor wanted.
- sportfan999
-
1000+ posts
a every () seconds block!
https://scratch-mit-edu.ezproxyberklee.flo.org/projects/382631312/editori n t e r e s t i n g
But yeah, use the workarounds that @fdreerf wrote, especially the “days since 2000” block one because the “days since 2000” block is just dope.
- chrdagos
-
500+ posts
a every () seconds block!
what if the code in the C-loop takes longer to execute than the number of seconds that of which was defined. more specifically, what would happen if i made this:
every (5) seconds{would it wait until the code in it finished executing or would it stop execution and go to the beginning of the code, repeating this proccess?
wait (8) secs
} :: control
- NanoPIex
-
500+ posts
a every () seconds block!
I think then we`d have a problema. what if the code in the C-loop takes longer to execute than the number of seconds that of which was defined. more specifically, what would happen if i made this:every (5) seconds{would it wait until the code in it finished executing or would it stop execution and go to the beginning of the code, repeating this proccess?
wait (8) secs
} :: control
- CST1229
-
1000+ posts
a every () seconds block!
I think running a broadcast script twice in quick succession cancels the script and restarts it, so I think the same thing will apply for this. what if the code in the C-loop takes longer to execute than the number of seconds that of which was defined. more specifically, what would happen if i made this:every (5) seconds{would it wait until the code in it finished executing or would it stop execution and go to the beginning of the code, repeating this proccess?
wait (8) secs
} :: control
Besides, you can just use a wait block in a forever script.
- NanoPIex
-
500+ posts
a every () seconds block!
No support due to this two-block workaround:I think running a broadcast script twice in quick succession cancels the script and restarts it, so I think the same thing will apply for this. what if the code in the C-loop takes longer to execute than the number of seconds that of which was defined. more specifically, what would happen if i made this:every (5) seconds{would it wait until the code in it finished executing or would it stop execution and go to the beginning of the code, repeating this proccess?
wait (8) secs
} :: control
Besides, you can just use a wait block in a forever script.
forever
wait (...) secs
end
- Tunde123
-
1000+ posts
a every () seconds block!
Agreed. No support because of the quoted text above. No support due to this two-block workaround:forever
wait (...) secs
end
Last edited by Tunde123 (Dec. 5, 2020 16:32:40)
- gosoccerboy5
-
1000+ posts
a every () seconds block!
Tip: with ScratchBlox syntax, you can use a curly bracket to denote a c loop or whatever. Here's an example:
This turns into
Anyways, I'd have to say no support because of the workaround. You can execute code and wait a few seconds in a forever loop, detect when timer mod (x) is 0, you can mess with broadcasts, or you can get fancy with the days since 2000 block. If custom c blocks ever get added, it'll make it even easier to work around this. It's a good suggestion though
repeat until broadcast [message v] received? {
...
} :: control
repeat until broadcast [message v] received? {
...
} :: control
Anyways, I'd have to say no support because of the workaround. You can execute code and wait a few seconds in a forever loop, detect when timer mod (x) is 0, you can mess with broadcasts, or you can get fancy with the days since 2000 block. If custom c blocks ever get added, it'll make it even easier to work around this. It's a good suggestion though

- NanoPIex
-
500+ posts
a every () seconds block!
lolAgreed. No support because of the quoted text above. No support due to this two-block workaround:forever
wait (...) secs
end
- Maximouse
-
1000+ posts
a every () seconds block!
No support because it isn't much harder to do this without a special block.
- mybearworld
-
1000+ posts
a every () seconds block!
no support, as of the workaround people posted.
- NanoPIex
-
500+ posts
a every () seconds block!
Tip: with ScratchBlox syntax, you can use a curly bracket to denote a c loop or whatever. Here's an example:This turns intorepeat until broadcast [message v] received? {
...
} :: controlrepeat until broadcast [message v] received? {
...
} :: control
Anyways, I'd have to say no support because of the workaround. You can execute code and wait a few seconds in a forever loop, detect when timer mod (x) is 0, you can mess with broadcasts, or you can get fancy with the days since 2000 block. If custom c blocks ever get added, it'll make it even easier to work around this. It's a good suggestion though
- gosoccerboy5
-
1000+ posts
a every () seconds block!
I feel like you quoted me and replaced the quote with your name.
- HarmlessOstrich
-
100+ posts
a every () seconds block!
They DID! I feel like you quoted me and replaced the quote with your name.
- fdreerf
-
1000+ posts
a every () seconds block!
I think that the block would do what it says: execute the code every X seconds. So, in this example, every 5 seconds it will wait 8 seconds, and there will be some overlap where two scripts are running at once. I believe my latter two workarounds accomplish this. what if the code in the C-loop takes longer to execute than the number of seconds that of which was defined. more specifically, what would happen if i made this:every (5) seconds{would it wait until the code in it finished executing or would it stop execution and go to the beginning of the code, repeating this proccess?
wait (8) secs
} :: control