Discuss Scratch
- JonathanSchaffer
-
1000+ posts
2nd timer
I have ben making a cloud project lately, and I need two timers for it.
now my suggestion is that
now my suggestion is that
(timer)be changed to
(timer 1::sensing)and
(timer 2::sensing)added. both would function the same as the original, besides having individual times.
- -stache-
-
500+ posts
2nd timer
But it's workaround-able: I have ben making a cloud project lately, and I need two timers for it.
now my suggestion is that(timer)be changed to(timer 1::sensing)and(timer 2::sensing)added. both would function the same as the original, besides having individual times.
define create timerIf you need this block, you're doing something wrong.
add (days since 2000) to [timers v] // run this block to create a timer and assign it an ID (which is put in the return variable)
set [return v] to (length of [timers v] :: list)
define reset timer (timer id)
replace item (timer id) of [timers v] with (days since 2000) // this resets a timer given it's ID
define timer (timer id)
set [return v] to (((days since 2000) - (item (timer id) of [timers v] :: list)) * (86400)) // assigns return the seconds since the timer has been reset/created
- dvargasews
-
500+ posts
2nd timer
I was actually thinking that there should only be one timer at first, but there would be a button to add timers, like the button to add variables.
- stickfiregames
-
1000+ posts
2nd timer
I don't see why they should specifically have two timers - why not 3, or 10?
If you want to use multiple timers you can use this - make sure you don't reset the actual timer:
I do quite like dvargasews's idea of being able to create timers when you need them though.
If you want to use multiple timers you can use this - make sure you don't reset the actual timer:
set [timer 2 v] to (timer) // resets timer 2
((timer) - (timer 2)) // gets the value of timer 2
I do quite like dvargasews's idea of being able to create timers when you need them though.
- -stache-
-
500+ posts
2nd timer
cough I do quite like dvargasews's idea of being able to create timers when you need them though.
define create timer
add (days since 2000) to [timers v] // run this block to create a timer and assign it an ID (which is put in the return variable)
set [return v] to (length of [timers v] :: list)
define reset timer (timer id)
replace item (timer id) of [timers v] with (days since 2000) // this resets a timer given it's ID
define timer (timer id)
set [return v] to (((days since 2000) - (item (timer id) of [timers v] :: list)) * (86400)) // assigns return the seconds since the timer has been reset/created
- JonathanSchaffer
-
1000+ posts
2nd timer
But it's workaround-able: I have ben making a cloud project lately, and I need two timers for it.
now my suggestion is that(timer)be changed to(timer 1::sensing)and(timer 2::sensing)added. both would function the same as the original, besides having individual times.define create timerIf you need this block, you're doing something wrong.
add (days since 2000) to [timers v] // run this block to create a timer and assign it an ID (which is put in the return variable)
set [return v] to (length of [timers v] :: list)
define reset timer (timer id)
replace item (timer id) of [timers v] with (days since 2000) // this resets a timer given it's ID
define timer (timer id)
set [return v] to (((days since 2000) - (item (timer id) of [timers v] :: list)) * (86400)) // assigns return the seconds since the timer has been reset/created

- JonathanSchaffer
-
1000+ posts
2nd timer
but I DO need to reset them BOTH I don't see why they should specifically have two timers - why not 3, or 10?
If you want to use multiple timers you can use this - make sure you don't reset the actual timer:set [timer 2 v] to (timer) // resets timer 2
((timer) - (timer 2)) // gets the value of timer 2
I do quite like dvargasews's idea of being able to create timers when you need them though.
- stickfire-test
-
100+ posts
2nd timer
Then make two variable-based timers - timer 1 and timer 2.but I DO need to reset them BOTH I don't see why they should specifically have two timers - why not 3, or 10?
If you want to use multiple timers you can use this - make sure you don't reset the actual timer:set [timer 2 v] to (timer) // resets timer 2
((timer) - (timer 2)) // gets the value of timer 2
I do quite like dvargasews's idea of being able to create timers when you need them though.
Last edited by stickfire-test (Dec. 19, 2016 13:34:19)
- ZZ9PluralZAlpha
-
1000+ posts
2nd timer
Workaround for the timers. You can have the current timer, but you can also have timers as variables:-
(Timer 2 :: variables)and use this script:-
when green flag clickedAnd if you wanted to pause or stop that timer, make something send a broadcast, then use
forever
wait (1) secs // Change this for how accurate you want the timer to be
change [Timer 2 v] by [1] // Keep this value the same as the other one
end
when I receive [Stop Timer 2 v]I see where you are going with this, but due to the workaround, half support only.
stop [other scripts in sprite v]
- Sigton
-
1000+ posts
2nd timer
-stache-?who would ever think of that?

That's a great workaround, it's easy to use and allows unlimited timers.
-stache-'s workaround… but I DO need to reset them BOTH
Sigton
Last edited by Sigton (Dec. 19, 2016 17:13:13)
- ZZ9PluralZAlpha
-
1000+ posts
2nd timer
Did you see my workaround as well?-stache-?who would ever think of that?
That's a great workaround, it's easy to use and allows unlimited timers.-stache-'s workaround… but I DO need to reset them BOTH
Sigton
- -stache-
-
500+ posts
2nd timer
Mewho would ever think of that?


It's pretty straightforward…
- -stache-
-
500+ posts
2nd timer
This workaround is inaccurate. The execution of one block takes an extra 0.01 seconds or so. That can change drastically between computers. In 100 seconds, that workaround would say about 101 seconds… Workaround for the timers. You can have the current timer, but you can also have timers as variables:-(Timer 2 :: variables)and use this script:-when green flag clickedAnd if you wanted to pause or stop that timer, make something send a broadcast, then use
forever
wait (1) secs // Change this for how accurate you want the timer to be
change [Timer 2 v] by [1] // Keep this value the same as the other one
endwhen I receive [Stop Timer 2 v]I see where you are going with this, but due to the workaround, half support only.
stop [other scripts in sprite v]
- ZZ9PluralZAlpha
-
1000+ posts
2nd timer
But it is good in theory, right?This workaround is inaccurate. The execution of one block takes an extra 0.01 seconds or so. That can change drastically between computers. In 100 seconds, that workaround would say about 101 seconds… Workaround for the timers. You can have the current timer, but you can also have timers as variables:-(Timer 2 :: variables)and use this script:-when green flag clickedAnd if you wanted to pause or stop that timer, make something send a broadcast, then use
forever
wait (1) secs // Change this for how accurate you want the timer to be
change [Timer 2 v] by [1] // Keep this value the same as the other one
endwhen I receive [Stop Timer 2 v]I see where you are going with this, but due to the workaround, half support only.
stop [other scripts in sprite v]
- JonathanSchaffer
-
1000+ posts
2nd timer
but I like to understand the code I use.-stache-?who would ever think of that?
That's a great workaround, it's easy to use and allows unlimited timers.-stache-'s workaround… but I DO need to reset them BOTH
Sigton
- ZZ9PluralZAlpha
-
1000+ posts
2nd timer
Here you go @-stache-. Fixed it for you. In the quote.This workaround is (EDITED: FIXED)no longer inaccurate. The execution of one block takes an extra 0.01 seconds or so. That can change drastically between computers. In 100 seconds, that workaround would (no longer) say about 101 seconds… Workaround for the timers. You can have the current timer, but you can also have timers as variables:-(Timer 2 :: variables)and use this script:-when green flag clickedAnd if you wanted to pause or stop that timer, make something send a broadcast, then use
forever
wait (0.99) secs // Change this for how accurate you want the timer to be. @-stache-, this sorts your delay thing you mentioned.
change [Timer 2 v] by [1] // Keep this value the same as the other one
endwhen I receive [Stop Timer 2 v]I see where you are going with this, but due to the workaround, half support only.
stop [other scripts in sprite v]
Last edited by ZZ9PluralZAlpha (Dec. 19, 2016 17:48:59)
- JonathanSchaffer
-
1000+ posts
2nd timer
wrong it would say 99. (no offense)This workaround is inaccurate. The execution of one block takes an extra 0.01 seconds or so. That can change drastically between computers. In 100 seconds, that workaround would say about 101 seconds… Workaround for the timers. You can have the current timer, but you can also have timers as variables:-(Timer 2 :: variables)and use this script:-when green flag clickedAnd if you wanted to pause or stop that timer, make something send a broadcast, then use
forever
wait (1) secs // Change this for how accurate you want the timer to be
change [Timer 2 v] by [1] // Keep this value the same as the other one
endwhen I receive [Stop Timer 2 v]I see where you are going with this, but due to the workaround, half support only.
stop [other scripts in sprite v]
- -stache-
-
500+ posts
2nd timer
oopswrong it would say 99. (no offense)This workaround is inaccurate. The execution of one block takes an extra 0.01 seconds or so. That can change drastically between computers. In 100 seconds, that workaround would say about 101 seconds… Workaround for the timers. You can have the current timer, but you can also have timers as variables:-(Timer 2 :: variables)and use this script:-when green flag clickedAnd if you wanted to pause or stop that timer, make something send a broadcast, then use
forever
wait (1) secs // Change this for how accurate you want the timer to be
change [Timer 2 v] by [1] // Keep this value the same as the other one
endwhen I receive [Stop Timer 2 v]I see where you are going with this, but due to the workaround, half support only.
stop [other scripts in sprite v]

Last edited by -stache- (Dec. 19, 2016 17:56:12)
- -stache-
-
500+ posts
2nd timer
I said about, and it varies between computers, but that's averageHere you go @-stache-. Fixed it for you. In the quote.This workaround is (EDITED: FIXED)no longer inaccurate. The execution of one block takes an extra 0.01 seconds or so. That can change drastically between computers. In 100 seconds, that workaround would (no longer) say about 101 seconds… Workaround for the timers. You can have the current timer, but you can also have timers as variables:-(Timer 2 :: variables)and use this script:-when green flag clickedAnd if you wanted to pause or stop that timer, make something send a broadcast, then use
forever
wait (0.99) secs // Change this for how accurate you want the timer to be. @-stache-, this sorts your delay thing you mentioned.
change [Timer 2 v] by [1] // Keep this value the same as the other one
endwhen I receive [Stop Timer 2 v]I see where you are going with this, but due to the workaround, half support only.
stop [other scripts in sprite v]
- ZZ9PluralZAlpha
-
1000+ posts
2nd timer
So the wait would be 1.01? Or 0.99?oopswrong it would say 99. (no offense)This workaround is inaccurate. The execution of one block takes an extra 0.01 seconds or so. That can change drastically between computers. In 100 seconds, that workaround would say about 101 seconds… Workaround for the timers. You can have the current timer, but you can also have timers as variables:-(Timer 2 :: variables)and use this script:-when green flag clickedAnd if you wanted to pause or stop that timer, make something send a broadcast, then use
forever
wait (1) secs // Change this for how accurate you want the timer to be
change [Timer 2 v] by [1] // Keep this value the same as the other one
endwhen I receive [Stop Timer 2 v]I see where you are going with this, but due to the workaround, half support only.
stop [other scripts in sprite v]but still