Search code examples
javascriptgoogle-blockly

Blockly restrict input_value to another block


In my Blockly project, I have two 3 blocks rcm_a, rcm_b and rcm_c.

Blockly.defineBlocksWithJsonArray([{
  "type": "rcm_c",
  "message0": "Requirement block- rcm_a: %1 rcm_b: %2",
  "args0": [
    {
      "type": "input_value",
      "name": "rcm_a"
    },
    {
      "type": "input_value",
      "name": "rcm_b",
      "check": ["rcm_b"]
    }
  ],
  "output": "Text",
  "colour": "%{BKY_LOOPS_HUE}"
}]);

As you can see the above code of rcm_c, I am trying to restrict the second input to be of block rcm_b, and that apparently doesn't seem to be working. The same input will not accept any input type. Here's rcm_b's code:

Blockly.defineBlocksWithJsonArray([{
  "type": "rcm_b",
  "message0": "rcm_b %1",
  "args0": [
    {
      "type": "input_value",
      "name": "VALUE1",
      "check": "String"
    }
  ],
  "output": "Text",
  "colour": "%{BKY_LOOPS_HUE}"
}]);

I tried following this guide's Statement Stacks section (I am aware that I am trying to type check inputs and not statements) to achieve type-checking. What am I doing wrong?

Help is much appreciated!


Solution

  • Ah, seems like the 'output' of rcm_b needed to be rcm_b!