In other languages

Help the wiki!

The Scratch Wiki is made by and for Scratchers. Do you want to contribute?

Learn more about joining as an editor!

See discussions in the Community Portal

Wait () Secs (block)

"Wait" redirects here. For the other Control block with "wait" in its name, see Wait Until () (block).
Wait () Secs
2.0 Wait () Secs.png
Category Control
Type Stack
Introduced in 0.1

The Wait () Secs block is a Control block and a Stack block. The block pauses its script for the specified amount of seconds — the wait can also be a decimal number.

Example Uses

This block creates a pause whenever needed — as there are many situations where this is need, the block is used in many projects. Some common uses:

  • Timers
forever
 wait (60) secs
 next costume
repeat (10)
 wait (0.05) secs
 next costume
wait (300) secs
broadcast [Morning v]
when gf clicked
set [var v] to [0]
wait (0) secs
change [var v] by (1)
  • In the Flash Player, allowing the page to refresh so sprites can sense objects made by the pen.
stamp
go to x: (-50) y: (0)
wait (0) secs
repeat until <touching color [#000000]?>
change x by (1)
wait (0) secs
end

Workaround

Main article: List of Block Workarounds

This block can be replicated using any of the following scripts:

Using the Timer

reset timer
wait until <not <(timer) < (value)>>

However, if the project resets the timer for other purposes, a different workaround should be used.

set [variable v] to (timer)
wait until <not <((timer) - (variable)) < (wait duration)>>

The workaround uses the timer as a base instead of a player-made clock because the timer is more accurate; player-made clocks lag from the time it takes to change the clock variable.

Using Glide () Secs to X: () Y: ()

glide (wait duration) secs to x: (x position) y: (y position)

This workaround will muddle whatever movement the sprite is performing at the time, so it is best to keep the workaround to immobile sprites.

Using Say () for () Secs or Think () for () Secs

say [ ] for (wait duration) secs
think [ ] for (wait duration) secs

These two workarounds will ruin any thoughts or sayings that the sprite has at the time, so they should only be used on sprites that do not think or talk.

Using Rest for () Beats

rest for <((tempo) / (60)) * (wait duration)> beats

Using Play Sound () Until Done

Warning Note: This is assuming that the sound is exactly the wanted length.
play sound [silent sound v] until done
  • This page was last modified on 27 January 2014, at 00:56.