(Redirected from Action After Stop)

In some cases, it can be useful to have an action occur after the Stop Sign is pressed. Examples include giving a user a goodbye message, thumbnail fade-in effects, or logging off of a cloud project.

Scripts

Note Warning: The following scripts will keep your project actively running until you close the editor, player, or browser tab. Attempting to use the stop button to terminate the process will not work, since it will just restart the script.

The following scripts will be able to run a script after the stop sign is pressed.

Method 1

Note Note: The below script can be used without messing up other parts of the project even if the Timer is already used for other purposes, since this script uses a variable to set the timer.
when gf clicked
forever
set [stop detector v] to (timer)
end

when [timer v] > (stop detector)
...
stop [this script v]

The first script constantly keeps the stop detector variable slightly greater than the timer. When the project is stopped, the script no longer works, so the timer becomes greater than the stop detector. This then runs the second script.

Method 2

Note Caution: The following script given cannot be used if the timer is already in other parts of the project since this could cause the scripts in those parts to malfunction, as the timer is a global runtime value that will be the same anywhere in the project.
when gf clicked
forever
reset timer

when [timer v] > (0.1) // The right-hand value should typically not be lower than this, especially if you're running the project on a slow device or your project is very bulky.
...

The first script keeps the timer constantly at 0. This script will end once the project is stopped, allowing the timer to continue. The second script waits for this continuation, thereby running the script.

Examples

See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.