How to get a blocks check type

132 views
Skip to first unread message

OrrinOliver

unread,
Dec 6, 2021, 4:53:29 PM12/6/21
to Blockly
Is there a way to get a blocks check type while using var blocks = workspacePlayground.getTopBlocks(false);

I'm trying to find if a block has the custom check type of "Board"

Beka Westberg

unread,
Dec 7, 2021, 10:18:13 AM12/7/21
to blo...@googlegroups.com
Hello!

Firstly let me clarify that check types are associated with individual connections, not with blocks. For example you could have one connection with a check of ['String'] and another connection with a check if ['Number'].

So to get the check of a connection you can do:
```
var block = /* get access to a block */
var check = block.getInput('MY_INPUT_NAME').connection.getCheck();
```

or the following for the non-input connections:
```
var check = block.outputConnection.getCheck();
var check = block.previousConnection.getCheck();
var check = block.nextConnection.getCheck();
```

Note that getCheck returns an *array of strings* not just a string.

I hope that helps! If you have any further questions please reply =)

Also, can I ask what this functionality is for? Sounds like part of an interesting problem!

Best wishes, I hope you have a lovely week!
--Beka


On Mon, Dec 6, 2021 at 4:53 PM OrrinOliver <skorm...@gmail.com> wrote:
Is there a way to get a blocks check type while using var blocks = workspacePlayground.getTopBlocks(false);

I'm trying to find if a block has the custom check type of "Board"

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/b49ad441-2786-407e-8f8e-c014e66f328en%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages