Damn again... I have currently a loop inside the code generator, to build the node.send statement:
// Send the message only to the specified output number, and null to all other outputs.
var outputArray = '';
for (var i = 1; i <= Blockly.nodeOutputs; i++) {
if (i > 1) {
outputArray += `, `;
}
if (i == outputNumber) {
outputArray += `${inputValue}`;
}
else {
outputArray += `null`;
}
}
var code = `if(${functionName}(${outputNumber})) {\n`;
code += ` node.send([ ${outputArray} ]);\n`;
code += `}\n`;
But since I don't know anymore at code-generation-time which output number will be used (since that is only determined at run-time), this means I have to put the above loop also in the generated Javascript. This will result in unreadable code. Don't like that. It should stay in the code generator, and be invisible to the users.
Isn't it better that we don't allow the output number to be generated at runtime. I.e. only allow a fixed number to be entered. The logic to determine which output needs to be used shouldn't be INSIDE the output_number input field, but instead AROUND our send-block. For example by using an if-block:
Otherwise nobody will understand the generated code anymore. Does this makes sense?
@TotallyInformation: Julian, would be nice to get your opinion. And also other users ...