Discuss Scratch
- HarmlessOstrich
 - 
                            
						
						
                            Scratcher
                        
						
						 
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
 it would repeat a code every () seconds- MDCCCLXVII
 - 
                            
						
						
                            Scratcher
                        
						
						 
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
 - 
                            
						
						
                            Scratcher
                        
						
						 
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
 - 
                            
						
						
                            Scratcher
                        
						
						 
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
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
a every () seconds block!
https://scratch.mit.edu/projects/382631312/editorThat's very cool but I don't believe that project has what the suggestor wanted.
- sportfan999
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
a every () seconds block!
https://scratch.mit.edu/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
 - 
                            
						
						
                            Scratcher
                        
						
						 
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{
wait (8) secs
} :: controlwould 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?- NanoPIex
 - 
                            
						
						
                            Scratcher
                        
						
						 
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:I think then we`d have a problema.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
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ 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: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.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
 - 
                            
						
						
                            Scratcher
                        
						
						 
500+ posts
a every () seconds block!
No support due to this two-block workaround: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: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.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
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
a every () seconds block!
No support due to this two-block workaround:Agreed. No support because of the quoted text above.forever
wait (...) secs
end
Last edited by Tunde123 (Dec. 5, 2020 16:32:40)
- gosoccerboy5
 - 
                            
						
						
                            Scratcher
                        
						
						 
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? {
...
} :: controlrepeat until broadcast [message v] received? {
...
} :: controlAnyways, 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
 - 
                            
						
						
                            Scratcher
                        
						
						 
500+ posts
a every () seconds block!
lolNo support due to this two-block workaround:Agreed. No support because of the quoted text above.forever
wait (...) secs
end
- Maximouse
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
a every () seconds block!
No support because it isn't much harder to do this without a special block.
                        
                        
                    - mybearworld
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
a every () seconds block!
no support, as of the workaround people posted.
                        
                        
                    - NanoPIex
 - 
                            
						
						
                            Scratcher
                        
						
						 
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
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
a every () seconds block!
I feel like you quoted me and replaced the quote with your name.
                        
                        
                    - HarmlessOstrich
 - 
                            
						
						
                            Scratcher
                        
						
						 
100+ posts
a every () seconds block!
I feel like you quoted me and replaced the quote with your name.They DID!
- fdreerf
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ 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: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.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
            










