motor_ = block.getFieldValue("turnMotor_");
if (motor_===undefined) motor_=0;
So now you check that value inside Blockly.JavaScript.motor_move_by_vel - if it's undefined you set the default value.
But what you were doing wouldn't work properly anyway - for instance if you make a bunch of blocks, and just the very last block doesn't have a motor set, all of the blocks will then have the motor set to 0 which I guess isn't what you want
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I mean, you could just do:
So now you check that value inside
Blockly.JavaScript.motor_move_by_vel
- if it's undefined you set the default value.But what you were doing wouldn't work properly anyway - for instance if you make a bunch of blocks, and just the very last block doesn't have a motor set, all of the blocks will then have the motor set to 0 which I guess isn't what you want