Custom block with Javascript

Hi guys!
I am writing, because I have one question:
Is it possible to create a logic custom block like “if”? I know that there are already logic block in Makecode, but I would like to create my own logic blocks like “if”, “if else” etc. Do you think it is possible? If yes please let me know how it should look like. I will be very very thankful:)
Have a nice day!

Short answer: No. You can add new blocks to the logic category but you can’t override any of the builtin ones like if/else

Longer answer: kinda, but it won’t be pretty

There are two key features of if/else that are not supported in custom blocks from extensions:

  1. They expand with multiple statement inputs (i.e. multiple “mouths” that you can put blocks in)
  2. They compile to actual if/else statements in TypeScript. All custom blocks must compile to a function call, so they can’t turn into a raw if/else statement (or any other language construct for that matter)

That being said, you can make something sort of like an if/else by making several different blocks that take in a boolean and a handler. That’s probably not what you’re looking for though.

Can you provide a little more information about what you want to achieve? Maybe a drawing of what you want the block to look like?

1 Like

Well, I would like to create the same block as “if” block that already exist. I need this just to make a program for DFRobot Maqueen Plus with Micro:bit V2. The reason I want to do this is because I would like to make this program with as many custom block as I want.