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.
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.
Use the repeat Block#
The repeat block is found in the Logic - Control category.
repetir (10)
fin
Connect the repeat Block#
Connect the repeat block to the when started block.
Move Blocks into the repeat Block#
Drag the drive for and turn for blocks inside of the repeat block.
Set the Repeat Number#
Select the repeat number to change how many times the blocks within the repeat block will run.
Other Types of Loops#
Use the forever Block#
If you want to repeat a sequence of actions forever, use 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.
interrumpir