Know what connection list current block is connected to

30 views
Skip to first unread message

Jonty Small

unread,
Nov 18, 2021, 12:05:44 PM11/18/21
to Blockly
Hi all,

I'm coming into a roadblock, and was looking for some help.

I have a block that needs to know the input types of its parent block. BUT specifically for the connection its on.

For example the input connections for "logic_if_mutating" block is twofold. FIrst there is the IF part, and second the DO part.

As such when looking at the checks there are 2 separate checks for type. (atleast for IF there is a check, if DO had one two we would have 2 arrays).

What i'd like to do is be able to identify to which connection my current block is connected to. Such that I can only loop through the first array to find all the possible types in the input.

At the moment my thinking is that i have to get the parent of the child. then somehow find the child through the connections on the parent. But i'm not finding it.

Is there a way to call get what i'm connected to from the childs perspective? Where it knows the specific connection its attatched to. Or how do identify the connection from the parent's point of view when given a block id of the child?

Best,
Jonty


Beka Westberg

unread,
Nov 19, 2021, 10:23:08 AM11/19/21
to blo...@googlegroups.com
Hello Jonty,

If I'm understanding your problem correctly, where you want to find the input connection your block is connected to, you can probably do something like this:
```
this.outputConnection.targetConnection;
// or
this.previousConnection.targetConnection;
```

I hope that helps! Best wishes,
--Beka

--
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/e7b4a561-5daa-4fce-abea-277e66962cd8n%40googlegroups.com.

Jonty Small

unread,
Nov 19, 2021, 11:37:39 AM11/19/21
to Blockly
Thats it! Thanks again!
Reply all
Reply to author
Forward
0 new messages