Discuss Scratch

gamerwithasolomanner
Scratcher
15 posts

How to add various time limits on scratch?

How to add various time limits on scratch?
existentialcrisises
Scratcher
100+ posts

How to add various time limits on scratch?

Without any more context (you sharing your project with us or explaining in detail what “time limits” mean), we can only guess what you mean. But if you just want a timer, you can create a variable named timer and then use this code:
forever
wait (1) secs
change [timer v] by (1)
end
If you want the timer to start and stop counting at various times, you can use another variable to track if the timer is currently supposed to be counting, and use an if block, like this:
forever
wait (1) secs
if <(Timer Supposed to Be Counting?) = [Yes]> then
change [timer v] by (1)
end
end
deck26
Scratcher
1000+ posts

How to add various time limits on scratch?

You can also use the built-in timer which is more accurate. To use it for multiple timers store the value at the start and look for the difference between the timer and your stored value being more than a value.

set [start-xy v] to (timer)
wait until <((timer) -(start-xy)) > [5]> // a 5 second timer without resetting the built-in timer so it can be used elsewhere, just don't reset it

Powered by DjangoBB