Discuss Scratch

roycefrog
Scratcher
3 posts

is there a way to detect if a scratch project was stopped?

is there a way to detect if a scratch project was stopped? i need this because i want my story to reset when its stopped. if a person leaves the project without resetting the project then it will think the player is still in the game and assign the next player player2
TrulyVix
Scratcher
33 posts

is there a way to detect if a scratch project was stopped?

roycefrog wrote:

is there a way to detect if a scratch project was stopped? i need this because i want my story to reset when its stopped. if a person leaves the project without resetting the project then it will think the player is still in the game and assign the next player player2
Hey- It won't.
Pixilized
Scratcher
100+ posts

is there a way to detect if a scratch project was stopped?

There is, actually! Use the scripts below. (This will not work if you reset the timer anywhere in your project)

when flag clicked
forever
set [stop detection v] to ((timer) + (0.1))

when [timer v] > (stop detection)
if <(timer) > (stop detection)> then //This if is necessary

End
roycefrog
Scratcher
3 posts

is there a way to detect if a scratch project was stopped?

Pixilized wrote:

There is, actually! Use the scripts below. (This will not work if you reset the timer anywhere in your project)

when flag clicked
forever
set [stop detection v] to ((timer) + (0.1))

when [timer v] > (stop detection)
if <(timer) > (stop detection)> then //This if is necessary

End


I will test it
XtremeScratch776
Scratcher
29 posts

is there a way to detect if a scratch project was stopped?

Pixilized wrote:

There is, actually! Use the scripts below. (This will not work if you reset the timer anywhere in your project)

when flag clicked
forever
set [stop detection v] to ((timer) + (0.1))

when [timer v] > (stop detection)
if <(timer) > (stop detection)> then //This if is necessary

End

I also have this ‘shorter version’ of the same script…

when green flag clicked
forever
reset timer
end

After this, to detect if the script has been stopped

when [timer v] > (0.000001)
...

You can look at CommandOS at my profile as an example…

Hope this helps
roycefrog
Scratcher
3 posts

is there a way to detect if a scratch project was stopped?

XtremeScratch776 wrote:

Pixilized wrote:

There is, actually! Use the scripts below. (This will not work if you reset the timer anywhere in your project)

when flag clicked
forever
set [stop detection v] to ((timer) + (0.1))

when [timer v] > (stop detection)
if <(timer) > (stop detection)> then //This if is necessary

End

I also have this ‘shorter version’ of the same script…

when green flag clicked
forever
reset timer
end

After this, to detect if the script has been stopped

when [timer v] > (0.000001)
...

You can look at CommandOS at my profile as an example…

Hope this helps


Pixilized wrote:

There is, actually! Use the scripts below. (This will not work if you reset the timer anywhere in your project)

when flag clicked
forever
set [stop detection v] to ((timer) + (0.1))

when [timer v] > (stop detection)
if <(timer) > (stop detection)> then //This if is necessary

End


Thank you both! This helped a lot.
Pixilized
Scratcher
100+ posts

is there a way to detect if a scratch project was stopped?

No problem! I’m glad I could help.
awesome-llama
Scratcher
1000+ posts

is there a way to detect if a scratch project was stopped?

You can't expect the user to stop the project to reset the cloud variables. Getting them all to follow instructions is difficult and even then it does not account of things such as loss of internet connection. In a project where I did require it to be stopped to reset it (it was an experiment with making a server), less than half of the users would reliably stop the project. I had to add in a way to remove them if they had been connected for too long.

What you can do is ensure that the players are sending their time or something else that is changing and detectable so that if they are no longer active, assume they have disconnected.

Powered by DjangoBB