Skip to main content

Conditional

Conditional statements, or if-then-else statements, help you to make more intelligent objects that can configure themselves automatically. For example we can create an object that looks like a grater or a saw from a block and a wedge.

We can now repeat this object with a repeat block. But what if we only want the wedges at the second half of the grater?

We can drag an if block and put the statement for the wedge inside. We now set the rule that this wedge should only be drawn if the iteration is larger than 5.

You can also specify that the wedge should be displayed only if the number of the iteration is dividable by 2. Just select the : operation. This means that the wedge will be displayed if the iteration if 2, 4, 6 and so forth.

The example below shows how the if statement is used to specify the height of the seats. It says that if the iteration is larger than 2 the height should be increased by 1. This means that the first 3 rows remain horizontal and next rows are lifted one step higher for each row.