• Thanks - I think you need to breakpoint your code eg Blockly.JavaScript.motor_move_by_angle and step through it with the chrome devtools.

    As far as I can tell:

    Blockly.JavaScript.motor_move_by_vel = function(block) {
        let vel = Blockly.JavaScript.valueToCode(this, 'vel', Blockly.JavaScript.ORDER_ASSIGNMENT) || '""';
        if(motorValid_ === false) {
            motor_ = 0;  <-----------------------  here because motorValid never got set
        }
        else {
            motor_ = block.getFieldValue("turnMotor_") <--- never gets called
    

    My guess is validate only ever gets called on user input, and not when the code is loaded.

    But either way a global motorValid_ sounds bad - for instance it's just set to the valid state of the last block checked, not to that of all the blocks. Personally I'd remove validate and just check what's going on when creating the code in Blockly.JavaScript.*

About

Avatar for Gordon @Gordon started