Discuss Scratch

SandboxDragons
Scratcher
6 posts

Start and Stop function

Is there a way to keep code running even when you press stop (hehe guess what I'm asking this for)? I thought that was able to be fixed using the
when [ timer v] > ( )::control
block, but it is to no avail.

Here is my script:
when [ timer v] > (0.0000000000000000000000000001)::control
set volume to (40) %
play sound [ Good music v] until done
reset timer

when [ timer v] > (0.0000000000000000000000000001)::control
forever
reset timer
wait (1) second::control
I know that the timer can be reset and I thought I could take advantage of that because even when you press stop the timer keeps going. How do I fix my code so that it is immune to the stop button?

Oh, I see you have stumbled across my signature.
Check out my new project:
https://scratch.mit.edu/projects/574408047/
when I receive [ NOT FOLLOWED!!! v]
say [Give that follow button a lil' bap and I'll give you one Scratch Ingot!]
wait until <(Follow Status) = [FOLLOWED!]>
change [ Scratch Ingots v] by (1)
stop [ sending this message v]
theanonymousweirdo
Scratcher
500+ posts

Start and Stop function

when green flag clicked
reset timer
set [variable v] to [1]
forever
turn cw [15] degrees
set [timer variable v] to ((timer)+[0.1])
end
when [timer v] > (timer variable)
set [variable v] to [0]
repeat until <(variable) = [1]>
turn cw [15] degrees
set [timer variable v] to ((timer) +[0.1])
end

Last edited by theanonymousweirdo (Dec. 7, 2021 05:37:08)


This is my signature. It appears at the bottom of all of my posts.
My favorite song: You're Not Alone
SandboxDragons
Scratcher
6 posts

Start and Stop function

theanonymousweirdo wrote:

when green flag clicked
reset timer
set [variable v] to [1]
forever
turn cw [15] degrees
set [timer variable v] to ((timer)+[0.1])
end
when [timer v] > (timer variable)
set [variable v] to [0]
repeat until <(variable) = [1]>
turn cw [15] degrees
set [timer variable v] to ((timer) +[0.1])
end
Ok? I'll try that, even though my gut instinct says that that won't work?

Oh, I see you have stumbled across my signature.
Check out my new project:
https://scratch.mit.edu/projects/574408047/
when I receive [ NOT FOLLOWED!!! v]
say [Give that follow button a lil' bap and I'll give you one Scratch Ingot!]
wait until <(Follow Status) = [FOLLOWED!]>
change [ Scratch Ingots v] by (1)
stop [ sending this message v]
deck26
Scratcher
1000+ posts

Start and Stop function

You need to reset the timer in a forever loop in a normal script, not a ‘when timer > ’ script. Then put your code to run when stop happens in a ‘when timer > ’ script. At that point the timer is going to be running normally.

Your version is resetting the timer all the time so it going to restart all the scripts repatedly.

Powered by DjangoBB