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.
|Warning:||The following scripts will make your project run continuously until you close the editor, player, or browser tab.|
The following scripts will be able to run a script after the stop sign is pressed.
|Note:||The following script given can be used if the timer is already used for other purposes, since this uses a variable to set the timer.|
when gf clicked forever set [stop detector v] to ((timer)+(0.1)) end when [timer v] > (stop detector) if <(timer) > (stop detector)> then // Due to the beginning value of stop detector being 0, this is needed. ... end 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.
|Caution:||The following script given cannot be used if the timer is already used for other purposes since this could break the project, as it constantly resets the timer.|
when gf clicked forever reset timer when [timer v] > (0.3) // The number input may be lowered for a shorter delay. ...
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.