# How do I make connecting cable between 'Button' and 'Bulb'?

Get help using Construct 2

### » Tue Aug 16, 2016 12:02 pm

Hey guys,

I making the simply platform / puzzle logic game. But I was stuck at a standstill...

I have no idea, how to make a "cable" - connecting chain between 2 or more objects which is builded from the same parts like simply rectangular section. For example, i have 'rectangle' named 'cable', 'the bulb' and the 'button'. But there is a path of 'cable' sections (5 or more duplications of cable) which makes a chain. So, I can't make just: "Button is overlapping cable" & "Cable is overlapping bulb" because it will make only 'remote' connecting , so even if chain of 'cables' will be not complete (like on the image below) the bulb will still work, because of condition "cable is overlapping bulb".

So is there just a simply method to make that chain in C2?
Can anybody help me, explain that method, or make simply example in C2?

I would be very grateful!!

B
4
Posts: 34
Reputation: 268

### » Tue Aug 16, 2016 1:00 pm

Basic idea is using flood-fill method to check whether any piece is part of the cable or not started from initial tip. Yes it use overlapping test to achieve that kind of mechanic.
B
133
S
55
G
24
Posts: 802
Reputation: 24,412

### » Tue Aug 16, 2016 1:09 pm

alextro, can you explain a little bit more how that flood-fill method works, or where can i find tutorial for this?
B
4
Posts: 34
Reputation: 268

### » Tue Aug 16, 2016 4:49 pm

If the chain parts are to be placed on a predefined path, you can make a variable which can count how many chain parts are placed,
if all 5 are placed correctly + its overlapping button + its overlapping bulb = Light the bulb
And if any of those 3 conditions are not true, it wont light up
B
9
S
2
Posts: 77
Reputation: 741

### » Tue Aug 16, 2016 6:23 pm

Thank you, this is not bad solution, but not perfect.. If i want to make 50-70 different levels so i have to make 50-70 different paths and 50-70 conditions to these.. so its not exactly what i want to do. I want to make something like "modules" which can i add to random levels, when i'll design them, and they'll work with the same conditions - just flexible modules, which can help designing levels and build them very easy.

So if I could make 'clever' chain, checking all connectivity - so i'll be able to make different levels using the same assets, which are "programmed" at beginning.
Im not sure if all these stuff is understanding My english isn't perfect, but i hopy you can understand, what I want to do

If you know about Lego power functions - so its something like that Just different modules like engine, power bank(batteries) , switches, lights - which you can combine in many configurations, but every of these has their own conditions, mechanics.. But i afraid its impossible to do in C2
B
4
Posts: 34
Reputation: 268

### » Tue Aug 16, 2016 11:35 pm

Always solvable with math and an array & a grid to reduce the possibilities.
But, you said overlapping dont work so i used overlapping.

https://www.dropbox.com/s/k2dcuymlcsxbh ... .capx?dl=0

Only moves on the grid with the tile = 1 are allowed. So, predefined paths are (boring) easy to define in the layout.
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Wed Aug 17, 2016 5:58 am

B
133
S
55
G
24
Posts: 802
Reputation: 24,412

### » Wed Aug 17, 2016 3:17 pm

99instances2Go - unfortunely I cant open your file, because I'm using old version r209 (neweer versions doesn't work on my laptop.. i don't know why, there is error..) So i cant see what you've done

alextro, its perfect what you did I think its exactly what i want. You are genius (Im noob but im learning this software hah). So I dont know how it works specially, I tried to analyse the event sheet, but i cant understand all of these conditions and actions I tested "toggle disable" to the action - 'peg destroy' to better understand how it works , and for "Repeat 10 times" condition - so its just a difference between gradually filling, and immediate filling, right?

And i dont know how work condition: 'For "" from 0 to 3' , can you explain me that in easy way xD ?
I will be grateful, because if I want to use that mechanic, I think, i should understand all of the conditions and actions.

I will test that in my game
Thank you very much
B
4
Posts: 34
Reputation: 268