I am new to blockly and I am playing arround with creating custom blocks.
I've created a new file (move.js) in the blocks folder and there I created some custom blocks. All of them have similar structure, like the one below
Blockly.Blocks['move_forward'] = {
init: function() {
this.appendDummyInput()
.appendField("Move Forward");
this.appendDummyInput()
.appendField(new Blockly.FieldImage("http://iosites.org/robotino/front.png", 20, 20, "Forward"));
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(120);
this.setTooltip('');
this.setHelpUrl('http://www.example.com/');
}
};
Then I created a new file (move.js) in the generators/javascript folder and there I wrote very simple generators for the blocks (they only return a letter).
Blockly.JavaScript['move_forward'] = function(block) {
return ['F;'];
};
The blocks work OK and return the text they are supposed to when stacked outside loops. But when I nest them inside a repeat or a while loop something happens and there is nothing returning. I have done some testing and I think that the problem occurs when the
Blockly.JavaScript.statementToCode
is called inside the repeat generator for my custom blocks.