Discuss Scratch

Jackson9050
Scratcher
64 posts

how do you stop timers?

im making a game that has a infinite timer that keeps going up, but i want to stop my timer after the player gets a certain amount of points, can somebody tell me how?
awesome-llama
Scratcher
1000+ posts

how do you stop timers?

You can't stop the in-built timer. You'll have to use a variable to record the time. If you want the variable to count up like the timer, try this:

reset timer
repeat until <(points) > [10]>
set [time v] to (timer)
end

The timer will be set only until the score is reached.

Last edited by awesome-llama (March 29, 2021 16:54:53)

Jackson9050
Scratcher
64 posts

how do you stop timers?

okay, thanks for telling me
Jackson9050
Scratcher
64 posts

how do you stop timers?

it didn't work, can you make a game with the code for it inside so i can use the code from that for my game?

Last edited by Jackson9050 (March 30, 2021 14:33:33)

awesome-llama
Scratcher
1000+ posts

how do you stop timers?

Jackson9050 wrote:

it didn't work, can you make a game with the code for it inside so i can use the code from that for my game?

It's only a simple script. There is nothing that can go wrong. The moment it is run (trigger it with a hat block of your choice), the timer variable starts and will count until the points are reached (which would be more than 10 in my example).
I don't want to create a project because it would contain that single script and nothing else.
patatiextrema
Scratcher
46 posts

how do you stop timers?

reset timer

That will make that the timer resets

Jackson9050 wrote:

it didn't work, can you make a game with the code for it inside so i can use the code from that for my game?

SamF2010
Scratcher
100+ posts

how do you stop timers?

You could just do a variable. A script like this:
when green flag clicked
set [timer] to [0]
set [playing?] to [true]
if <[playing?] = [true]> then
wait (1) secs
change [timer] by (1)
end
Or maybe you want a countdown:
Same script but make the timer equal to the amount of seconds you want it to be and change it by -1

Last edited by SamF2010 (March 31, 2021 14:22:52)

Jackson9050
Scratcher
64 posts

how do you stop timers?

i'll just try the one SamF2010 Said Cuz awesome-llama's one is so complicated
Jackson9050
Scratcher
64 posts

how do you stop timers?

SamF2010 wrote:

You could just do a variable. A script like this:
when green flag clicked
set [timer] to [0]
set [playing?] to [true]
if <[playing?] = [true]> then
wait (1) secs
change [timer] by (1)
end
Or maybe you want a countdown:
Same script but make the timer equal to the amount of seconds you want it to be and change it by -1
it worked! thanks for telling me, i also finished the thing i was making: https://scratch.mit.edu/projects/506055405/
i credited all of you who replyed to this post in my game.
---CloudTest---
Scratcher
7 posts

how do you stop timers?

Jackson9050 wrote:

SamF2010 wrote:

You could just do a variable. A script like this:
when green flag clicked
set [timer] to [0]
set [playing?] to [true]
if <[playing?] = [true]> then
wait (1) secs
change [timer] by (1)
end
Or maybe you want a countdown:
Same script but make the timer equal to the amount of seconds you want it to be and change it by -1
it worked! thanks for telling me, i also finished the thing i was making: https://scratch.mit.edu/projects/506055405/
i credited all of you who replyed to this post in my game.
scratch's repeat loops have a built-in function where it has a 0.1 second delay in a list for animating, so that means the timer you built is going a little off every second, you should change the wait 1 seconds to about wait 0.9 seconds, hope that helps
UltraGamer_Studios
Scratcher
96 posts

how do you stop timers?

Try this: https://scratch.mit.edu/projects/510359302/


when green flag clicked
forever
if <(Time Stopped) = [0]> then
change [Timer v] by (timer)
end
reset timer
end

Last edited by UltraGamer_Studios (April 1, 2021 16:52:20)

Jackson9050
Scratcher
64 posts

how do you stop timers?

---CloudTest--- wrote:

Jackson9050 wrote:

SamF2010 wrote:

You could just do a variable. A script like this:
when green flag clicked
set [timer] to [0]
set [playing?] to [true]
if <[playing?] = [true]> then
wait (1) secs
change [timer] by (1)
end
Or maybe you want a countdown:
Same script but make the timer equal to the amount of seconds you want it to be and change it by -1
it worked! thanks for telling me, i also finished the thing i was making: https://scratch.mit.edu/projects/506055405/
i credited all of you who replyed to this post in my game.
scratch's repeat loops have a built-in function where it has a 0.1 second delay in a list for animating, so that means the timer you built is going a little off every second, you should change the wait 1 seconds to about wait 0.9 seconds, hope that helps
thanks for telling me! cuz it did kinda looked weird.
PcUserPro
Scratcher
500+ posts

how do you stop timers?

\

Last edited by PcUserPro (April 2, 2021 04:05:27)

Jackson9050
Scratcher
64 posts

how do you stop timers?

PcUserPro wrote:

\
\
snapkin
Scratcher
72 posts

how do you stop timers?

Jackson9050 wrote:

i'll just try the one SamF2010 Said Cuz awesome-llama's one is so complicated
awesome-llama's one is only a few blocks but SamF2010's is more blocks. So I'm trying awesome-llama's one.
mmnagelia
Scratcher
100+ posts

how do you stop timers?

snapkin wrote:

Jackson9050 wrote:

i'll just try the one SamF2010 Said Cuz awesome-llama's one is so complicated
awesome-llama's one is only a few blocks but SamF2010's is more blocks. So I'm trying awesome-llama's one.
Number of blocks doesn't matter, quality and functionality matters. I personally like SamF2010's one since using a variable is more robust and gives you more control then the Scratch pre-built one.
snapkin
Scratcher
72 posts

how do you stop timers?

Jackson9050 wrote:

PcUserPro wrote:

\
\
\
mmnagelia
Scratcher
100+ posts

how do you stop timers?

snapkin wrote:

Jackson9050 wrote:

PcUserPro wrote:

\
\
\
Please don't spam.
Jackson9050
Scratcher
64 posts

how do you stop timers?

i'm just gonna close this cuz i got what i needed on april 1st

Powered by DjangoBB