How do I control several doors with different levers?

Get help using Construct 2

Post » Mon Mar 27, 2017 10:09 am

I want to make doors open using levers that are placed either next or far from a door. I also want these to affect each other through having the same variable. For example, lever 0 controls door 0, lever 1 controls door 1 and lever 2 controls door 2. One lever might even controls two doors if they share the same value, or vice versa. So instead of making more sprites for each lever, I want to just set their values the same.

How do I compare this in the events sheet?

Could someone show an "example picture" or explain this to me? Thanks.
B
4
Posts: 12
Reputation: 224

Post » Mon Mar 27, 2017 11:10 am

Image Image Image
B
32
S
12
G
27
Posts: 761
Reputation: 17,246

Post » Mon Mar 27, 2017 11:32 am


It seems to work quite nicely. The first enemy opens the first door. They all have the same variable at 0 however. How did you connect the first enemy with the first door exactly? I want to be able to set the variable to the same for those to connect.
B
4
Posts: 12
Reputation: 224

Post » Mon Mar 27, 2017 12:01 pm

ErikSwahn wrote: It seems to work quite nicely. The first enemy opens the first door. They all have the same variable at 0 however. How did you connect the first enemy with the first door exactly?

They all start with variable at 0 so on the:

On start of Layout | set InstVar to Self.IID
it replaces the variable with each object's respective INSTANCE ID. You could start there or manually assign the variables.

I like using that since it takes less work. Now it's just a matter of repositioning the enemy sprites. You can even modify the capx so instead of destroying the enemy it simply toggles a variable to open/close doors...
Image Image Image
B
32
S
12
G
27
Posts: 761
Reputation: 17,246

Post » Mon Mar 27, 2017 12:11 pm

MPPlantOfficial wrote:
ErikSwahn wrote: It seems to work quite nicely. The first enemy opens the first door. They all have the same variable at 0 however. How did you connect the first enemy with the first door exactly?

They all start with variable at 0 so on the:

On start of Layout | set InstVar to Self.IID
it replaces the variable with each object's respective INSTANCE ID. You could start there or manually assign the variables.

I like using that since it takes less work. Now it's just a matter of repositioning the enemy sprites. You can even modify the capx so instead of destroying the enemy it simply toggles a variable to open/close doors...


Aha, but is there no way to compare if they just have the same value to an instance variable called "type"? If they both have one and shares the number "0" for example. It would be super easy to just drag in the "lever" and the "door" and then set their instance variable's value ("type") to "0".
B
4
Posts: 12
Reputation: 224

Post » Mon Mar 27, 2017 12:16 pm

ErikSwahn wrote:Aha, but is there no way to compare if they just have the same value to an instance variable called "type"? If they both have one and shares the number "0" for example. It would be super easy to just drag in the "lever" and the "door" and then set their instance variable's value ("type") to "0".

Of course there is. Just create the new variable yourself. You can assign it to either the family or the objects themselves.
Image Image Image
B
32
S
12
G
27
Posts: 761
Reputation: 17,246

Post » Mon Mar 27, 2017 12:24 pm

I am such an idiot. Did not think of the "compare instance variable" condition with "door.type" = "lever.type" etc.

Many thanks though! :D
B
4
Posts: 12
Reputation: 224


Return to How do I....?

Who is online

Users browsing this forum: pcfernandesjr and 26 guests