Hello all,
I have created a custom block using to add two variables or numbers namely 'addvar'. It is generating python code as presented below.
{
name: 'addvar',
category: 'Logic',
block: {
init: function () {
this.jsonInit({
type: "add_to_var",
message0: "Add %1 with %2",
args0: [
{
type: "input_value",
name: "First",
//check: "Number"
},
{
type: "input_value",
name: "Second",
//check: "Number"
}
],
//previousBlock: "Action",
//nextStatement: true,
output: 'Number',
colour: 285,
tooltip: "Add two variables",
helpUrl: ""
});
},
},
generator: (block) => {
var value_first = Blockly.Python.valueToCode(block, 'First', Blockly.Python.ORDER_ATOMIC);
var value_second = Blockly.Python.valueToCode(block, 'Second', Blockly.Python.ORDER_ATOMIC);
var code = '('+value_first+"+"+value_second+')\n';
return code;
},
}
The code crashes whenever I use the set var function in the variables section to set a variable equaling the sum of two variables (k = m+n). I am sharing the stack trace part for my crashed code. I am using React application to render the Blockly environment. I am using BlocklyDrawer to code blocks.
If anybody knows how to fix the problem please help.
If there is any other way to render blocks please help? I am stuck in this problem for a long time. Please help.