Lets say i use the default 'controls_if' block. Where the user is able to mutate the block by adding multiple elseif and a else input for statement blocks.
If i run
let statements = MyJsonGenerator.statementToCode(block, "ELSE")
And I have not added an else input, I get an empty string as the return value.
And if I have added an else input, but not added any statement blocks, I also get an empty string as the return value.
And the problem is that I want to do different things depending the state it is in. Which I haven't found a way to do.
When the workspace is serialized I can see that an
extraState.hasElse = true property gets added. But I haven't found a way to access that from the generator. (aside from saving and reading from the saved workspace)
I don't know if it changes anything in this context, but since I generate JSON I have added
myJsonGenerator.scrub_ = function (block: Blockly.Block, code: String, opt_thisOnly: boolean) {
const nextBlock =
block.nextConnection && block.nextConnection.targetBlock();
if (nextBlock && !opt_thisOnly) {
return code + ',\n' + testSequenceGenerator.blockToCode(nextBlock)
}
return code;
};