Revision as of 21:46, 6 June 2022 by Jvvg (talk | contribs) (edit summary removed)

Repeat Until ()
repeat until <>
Category Control
Type Stack
Introduced in 1.1

The Repeat Until () block is a Control block and a C block. Blocks held inside this block will loop until the specified boolean statement is true, in which case the code beneath the block (if any) will execute. This loop is in similar nature to a while loop in some other programming languages.

Example Uses

As this block loops pieces of code until a condition is true, the block is the best way to run code until a desired condition has been reached. Some common uses:

  • Moving a sprite until its X or Y position is at a certain amount
repeat until <(x position) = [100]>
move (10) steps
  • Having a sprite stick to the mouse until the mouse is not down
repeat until <not <mouse down?>>
go to (mouse pointer v)
  • Waiting for an event while performing an action
repeat until <. . .::grey>
. . .
reset timer
repeat until <(timer) > (limit)>
  . . .
  • Repeating a question until the user answers correctly
repeat until <(answer) = (correct answer)>
ask [question] and wait


Main article: List of Block Workarounds

This block can be worked around with the following code:

define repeat until
. . .
if <. . .::grey> then
stop [this script v]

This should be avoided when making one sprite one script projects, however.

See Also

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