please help me for blocks "setCheck", "setPreviousStatement" and "setNextStatement" how to handle,
this is my code, i am try to do main block inside one by one sub_block 1 to 4 but it's not working.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Custom Blockly Blocks</title>
<!-- Load Blockly -->
<script src="
https://unpkg.com/blockly/blockly.min.js"></script>
<style>
body {
font-family: sans-serif;
}
#blocklyDiv {
height: 480px;
width: 600px;
}
</style>
</head>
<body>
<h1>Blockly Custom Blocks Example</h1>
<div id="blocklyDiv"></div>
<xml id="toolbox" style="display: none">
<block type="main_block"></block>
<block type="sub_block_1"></block>
<block type="sub_block_2"></block>
<block type="sub_block_3"></block>
<block type="sub_block_4"></block>
</xml>
<script>
Blockly.Blocks['main_block'] = {
init: function() {
this.appendDummyInput()
.appendField("main block");
this.appendStatementInput("NAME")
.setCheck("sub_block_1");
this.setColour(230);
this.setTooltip("");
this.setHelpUrl("");
}
};
Blockly.Blocks['sub_block_1'] = {
init: function() {
this.appendDummyInput()
.appendField("sub block 1");
this.appendStatementInput("NAME")
.setCheck(null);
this.setPreviousStatement(true, null);
this.setNextStatement(true, "sub_block_2");
this.setColour(230);
this.setTooltip("");
this.setHelpUrl("");
}
};
Blockly.Blocks['sub_block_2'] = {
init: function() {
this.appendDummyInput()
.appendField("sub block 2");
this.appendStatementInput("NAME")
.setCheck(null);
this.setPreviousStatement(true, "sub_block_1");
this.setNextStatement(true, "sub_block_3");
this.setColour(230);
this.setTooltip("");
this.setHelpUrl("");
}
};
Blockly.Blocks['sub_block_3'] = {
init: function() {
this.appendDummyInput()
.appendField("sub block 3");
this.appendStatementInput("NAME")
.setCheck(null);
this.setPreviousStatement(true, "sub_block_2");
this.setNextStatement(true, "sub_block_4");
this.setColour(230);
this.setTooltip("");
this.setHelpUrl("");
}
};
Blockly.Blocks['sub_block_4'] = {
init: function() {
this.appendDummyInput()
.appendField("sub block 4");
this.appendStatementInput("NAME")
.setCheck(null);
this.setPreviousStatement(true, "sub_block_3");
this.setNextStatement(true, null);
this.setColour(230);
this.setTooltip("");
this.setHelpUrl("");
}
};
// Initialize Blockly
const workspace = Blockly.inject('blocklyDiv', {
toolbox: document.getElementById('toolbox')
});
</script>
</body>
</html>
Regards,
Naveen S.