Uso de bucles#

If you want your robot to repeat the same action multiple times, like driving in a square, you could right-click the blocks and select Duplicate from the context menu, and keep duplicating those blocks until they move in the pattern of a square. A simpler way, however, is to use the repeat block within the Logic - Control category.

Duplicate Blocks#

Right-click a block to open its context menu.

Screenshot of a block's right-click context menu, with Duplicate highlighted.

Select Duplicate to make a copy of the block, and any blocks connected below it. Repeat this until the blocks are duplicated as many times as you need.

Screenshot of a duplicated drive for and turn for block being dragged below the original blocks.

Use the repeat Block#

The repeat block is found in the Logic - Control category.

The repeat block.#
repetir (10)
fin

Connect the repeat Block#

Connect the repeat block to the when started block.

Screenshot of a repeat block being connected below a when started block.

Move Blocks into the repeat Block#

Drag the drive for and turn for blocks inside of the repeat block.

Screenshot of a drive for block being dragged inside of a repeat block.

Set the Repeat Number#

Select the repeat number to change how many times the blocks within the repeat block will run.

Screenshot of the repeat block's number highlighted, set to 4.

Other Types of Loops#

Use the forever Block#

If you want to repeat a sequence of actions forever, use the forever block.

The forever block.#
por siempre
fin

Use the break Block#

To break out of a loop, use the break block within a loop, to make the code exit the looping block immediately.

The break block.#
interrumpir