From Test-Scratch-Wiki

(Automated edit: Updated Test Wiki copy of English Wiki page.)
(Automated edit: Updated Test wiki copy of English wiki page)
 
Line 1: Line 1:
{{:Eng:Action After Stop/translate}}
+
{{:Eng:Action After Stop/translate}}In some cases, it can be useful to have an action occur after the [[Eng:Stop Sign|Stop Sign]] is pressed. Examples include giving a user a goodbye message, or logging off of a [[Eng:Cloud Data|cloud]] project.
In some cases, it can be useful to have an action occur after the [[Eng:Stop Sign|Stop Sign]] is pressed. Examples include giving a user a goodbye message, or logging off of a [[Eng:Cloud Data|cloud]] project.
 
  
 
== Script ==
 
== Script ==
 
===New Script===
 
===New Script===
  
{{note}}The following script given '''can''' be used if the [[Eng:Timer (block)|timer]] is already used for other purposes since this uses a [[Eng:variable|variable]] to set the [[Eng:Timer (value)|timer]].
+
{{note|The following script given '''can''' be used if the [[Eng:Timer (block)|timer]] is already used for other purposes since this uses a [[Eng:variable|variable]] to set the [[Eng:Timer (value)|timer]].}}
  
 
The following [[Eng:script|script]] shows how to make something happen after the stop sign is pressed.
 
The following [[Eng:script|script]] shows how to make something happen after the stop sign is pressed.

Latest revision as of 12:57, 15 March 2018

Translate: - English 
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, or logging off of a cloud project.

Script

New Script

Note 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.

The following script shows how to make something happen after the stop sign is pressed.

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]

Old Script

Note Caution: The following script given cannot be used if the timer is already used for other purposes since this could break the project.

The following script shows how to make something happen after the stop sign is pressed.

when gf clicked
forever
reset timer

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

Explanation

The first script keeps the timer constantly at 0. This script will stop once the project is stopped, allowing the timer to continue. The second script waits for this continuation, thereby running a script. On the updated script, its sets the variable to the timer plus 0.1, so when the project stops, the variable stops updating but the timer continues.

Examples

See Also