Skip to content

Instantly share code, notes, and snippets.

@samelhusseini
Created June 10, 2020 17:05
Show Gist options
  • Save samelhusseini/dc55960c40c859a4dd315b78319ee28a to your computer and use it in GitHub Desktop.
Save samelhusseini/dc55960c40c859a4dd315b78319ee28a to your computer and use it in GitHub Desktop.
Chained If / else blocks
Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
{
"type": "custom_if",
"message0": "if %1 %2",
"args0": [
{
"type": "input_value",
"name": "NAME"
},
{
"type": "input_statement",
"name": "NAME"
}
],
"previousStatement": null,
"nextStatement": null,
"style": "logic_blocks",
"tooltip": "",
"helpUrl": ""
},
{
"type": "custom_else_if",
"message0": "else if %1 %2",
"args0": [
{
"type": "input_value",
"name": "NAME"
},
{
"type": "input_statement",
"name": "NAME"
}
],
"previousStatement": null,
"nextStatement": null,
"style": "logic_blocks",
"tooltip": "",
"helpUrl": ""
},
{
"type": "custom_else",
"message0": "else %1 %2",
"args0": [
{
"type": "input_dummy"
},
{
"type": "input_statement",
"name": "NAME"
}
],
"previousStatement": null,
"nextStatement": null,
"style": "logic_blocks",
"tooltip": "",
"helpUrl": ""
}
]);
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="custom_if">
<value name="NAME">
<block type="logic_operation">
<field name="OP">AND</field>
</block>
</value>
<next>
<block type="custom_else_if">
<value name="NAME">
<block type="logic_operation">
<field name="OP">AND</field>
</block>
</value>
<next>
<block type="custom_else"></block>
</next>
</block>
</next>
</block>
</xml>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment