- The correct title of this article is When () > () (block). The Scratch Wiki uses this different title because of technical restrictions.
|When () > ()|
When () > () block is an Events Block and a Hat Block. It starts the script below it when a value (chosen by the dropdown menu) is greater than another value (entered by the number input). The available options are loudness, timer, and video motion.
This hat block will only re-run after its condition first stops being met, and then begins being met again. If the script is running when the condition stops and the starts being met, this will be ignored and the script will not be restarted.
For example, in the below snippet, the sprite will move by 10 steps only.
when [timer v] > (1) ::hat events // Script "A" wait (10) secs move (10) steps when green flag clicked // Script "B" wait (2) secs reset timer
When the timer gets to 1 for a second time, "A" will still be running and so will not register that change.
However, in the below snippet, the sprite will move by 20 steps.
when [timer v] > (1) ::hat events // Script "A" wait (10) secs move (10) steps when green flag clicked // Script "B" wait (1) secs // Wait for "A" to start wait (9.5) secs reset timer
After "A" stops, it'll have half a second before the condition becomes true again; so it'll run twice, thus moving twenty steps.
- Main article: Loudness (value)
The loudness in the drop-down menu represents the volume of the sound that the computer microphone is picking up. The highest value is 100, and the lowest value is 1. Once the loudness is higher than the chosen amount, the script will begin to run.
- Main article: Timer (value)
The timer variable is default on Scratch and constantly running, and it can be reset. It counts up from 0. Once the timer's value is greater than the chosen time, the script will run.
- Main article: Video () on () (block)
Video motion uses optical flow from the video input.
This block can be used for many things, such as:
- Saying something when voice is entered
when [loudness v] > (10) say [Be quiet!] for (2) secs
- Being motion activated
when [video motion v] > (10) broadcast [start v]
- Starting something after a delay
when [timer v] > (10) broadcast [end game v]
- Main article: List of Block Workarounds
forever wait until <(loudness) > (20)> . . . wait until <not <(loudness) > (20)>>
Unceasing Timer Exploit
This event block has been occasionally used to create projects that can not be stopped. The following blocks cannot be stopped by pressing the red stop sign once the project has started.
when [timer v] > (0) reset timer forever reset timer . . . end
This method can be used to simulate a When Stop Clicked block.