I'm new to Blockly. To learn how to create a Custom Block, I used https://developers.google.com/blockly/guides/configure/web/toolbox#json. I copied portions of this text to an HTML file:
'''
<body>
<div id="blocklyDiv"></div>
<script>
var toolbox =
{
"kind": "categoryToolbox",
"contents": [
{
"kind": "category",
"name": "Core",
"contents": [
{
"kind": "block",
"type": "controls_if"
},
{
"kind": "block",
"type": "logic_compare"
},
]
},
{
"kind": "category",
"name": "Custom",
"contents": [
{
"kind": "block",
"type": "start"
},
{
"kind": "category",
"name": "Move",
"contents": [
{
"kind": "block",
"type": "move_forward"
}
]
},
{
"kind": "category",
"name": "Turn",
"contents": [
{
"kind": "block",
"type": "turn_left"
}
]
}
]
}
]
}
var workspace = Blockly.inject('blocklyDiv', {toolbox: toolbox});
</script>
'''
Using VSCode -> F5 --- results in this on a Chrome browser -> https://snipboard.io/ToY9UW.jpg
Selecting the "Custom" icon -> https://snipboard.io/X9WIFH.jpg, the VSCode "Debug Console" shows -> https://snipboard.io/qkpXCi.jpg.
What code do I add to a .js file to define "start", to fix the Invalid Block Definition?
Diego D --- That is exactly what I need! The key is "Blockly.defineBlocksWithJsonArray()" as defined at https://developers.google.com/blockly/guides/configure/web/custom-blocks#json_array.