I recently tried to make an OOP solution for a method block and I got a mutator with a field array this.params. Tell me what I can do with a drop-down toolbox with parameters created in this way. I just haven't been able to implement it myself or with GPT yet. Please tell me which way to look. I new in Blockly but in need me
Code:Blockly.common.defineBlocks({ param_block: {
init() {
this.appendDummyInput()
.appendField('Параметр:')
.appendField(new Blockly.FieldTextInput('x'), 'name')
.appendField('тип')
.appendField(new Blockly.FieldDropdown([
['int', 'int'],
['str', 'str'],
['bool', 'bool']
]), 'type');
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(230);
}
}
});
// param_container
Blockly.common.defineBlocks({
param_container: {
init: function () {
this.appendDummyInput()
.appendField('Параметры');
this.setNextStatement(true, null);
this.setColour(260);
this.setTooltip('Контейнер для параметров метода');
}
}
});
const method = {
init: function () {
this.params = [];
this.appendDummyInput('NAME')
.appendField('method')
.appendField(new Blockly.FieldTextInput('methodname'), 'NAME')
this.appendStatementInput('Code').appendField('Code');
this.appendValueInput('Return').appendField('Return');
this.setInputsInline(false);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Метод класса с параметрами');
this.setHelpUrl('');
this.setMutator(new Blockly.icons.MutatorIcon(['param_block'], this));
},
And any code...