How to use if blocks with On activate of blockly

I’m wondering how to use the if block with the on activate of. The if block has a little spot for blocks that have a bump on the left, and the on activate of has only a thing for stacks. Any advice on how to do this?

Hi @Levani_Tsiklauri!

The on Activate of - block will run all code you place inside of it when the item is clicked.

Code an be placed inside of the if - block as well, but before any code inside of the if - block runs, we need to check for a condition. Conditions can either be true, or false. If the condition which the if - block checks for is true, then it will run all code which you placed inside of it.

Here’s an example

First, we create the condition from the logic-category and attach it to the if - block.

If you press Play now, you’ll see the item running all code that you placed inside of the if-block. In this example we check if the number 0 is equal to the number 0, which is true. Use the dropdown next to the = - sign and try out different comparisons between numbers to see what else you can do with conditions!

Next, we can place this if-block inside of an on Activate of - block.

This is what happens now: when we press the item, the code will check if the condition of the if-block is true. When the condition is true, we’ll run the code inside of the if-block.

With our new CoBlocks coding language you can achieve the same results with less effort!

Hope this makes using if-blocks and their usage more clear to you.