How do I code this?

Get help using Construct 2

Post » Tue Nov 10, 2015 11:21 pm

Hi guys

I am trying to do something really simple but can't figure out how to use the code.

Basically I have 3 switches - each with an instance variable "name"

the names are 1, 2, 3

Im trying to code ...

If object lightswitch with instance variable "name" 1 is on Animation 2 AND
If object lightswitch with instance variable "name" 2 is on Animation 1 AND
If object lightswitch with instance variable "name" 3 is on Animation 2 Do Something

If Anybody could help, that would be awesome!

Thank you in advance!
B
43
S
21
G
9
Posts: 141
Reputation: 8,926

Post » Wed Nov 11, 2015 1:27 am

Check the instance variables animation frame... Then add a sub event to check the next IV
Eat ALL THE BACON!
B
45
S
17
G
3
Posts: 290
Reputation: 4,993

Post » Wed Nov 11, 2015 1:45 am

Thank you for your reply :)

I can't seem to figure out how to check an instance variables animation, all on one line.

Right now I have -> If Lightswitch and it's Name = 1 then ( this is all I can do one 1 line )

But what I need to have is ..

If Lighswitch with Name = 1 is playing Animation 1 then ...

I can only seem to get 2 conditions on per line :(

Basically, this is what I need ...

If Lighswitch with Instance Variable Name = 1, is playing Animation 1 AND
If Lighswitch with Instance Variable Name = 2, is playing Animation 2 AND
If Lighswitch with Instance Variable Name = 3, is playing Animation 1 AND
If Lighswitch with Instance Variable Name = 4, is playing Animation 2 THEN ...

I'm not sure however, if this is possible?
B
43
S
21
G
9
Posts: 141
Reputation: 8,926

Post » Wed Nov 11, 2015 9:08 am

@Ninjadoodle

Have you thought to use GLOBAL variable for each lightswitch, and then simply compare the value of these variables to trigger your event ?
When you trigger the switch, you change its animation frame and the global variable's value.
The other condition relies on the variable, not on the animation frame, furthermore with this you could create puzzles where each light can have a few different colors ;-)

I mean you could just "split" this in a few events :
- first for each lightswitch, when it's activated you change the global variable's value and set the light color according to this variable
- in the second you check the value of each GLOBAL variable and then trigger the action if variable 1 ="this value" and variable2 = "another value", etc, etc...
Hello !



I'm Steven, a 24 years old French graphic designer and programmer, and it's been 4 years since I started using Construct 2.
B
15
S
5
G
3
Posts: 69
Reputation: 2,521

Post » Wed Nov 11, 2015 9:50 am

Hi @Ratmaster

Thank you for the reply! Just before I checked this thread, I used this exact workaround :)

Thank you again, I really appreciate the help!
B
43
S
21
G
9
Posts: 141
Reputation: 8,926

Post » Wed Nov 11, 2015 10:13 am

Here is one way using multiple and. I'm not saying it's the best way…

https://goo.gl/JAUtxv
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
33
G
47
Posts: 1,194
Reputation: 30,812

Post » Wed Nov 11, 2015 10:27 am

@Ninjadoodle
You're welcome ;-)
What's great with global variables is that you can for example have switches in a dungeon that open a secret room in another dungeon or other complicated things and it's easy to organize ;-)

@RamPackWobble

I didn't know you could do it that way, thanks for sharing !
Hello !



I'm Steven, a 24 years old French graphic designer and programmer, and it's been 4 years since I started using Construct 2.
B
15
S
5
G
3
Posts: 69
Reputation: 2,521

Post » Wed Nov 11, 2015 9:57 pm

@RamPackWobble

Thanks heaps for the example, It does exactly what I need (but I would have never figured that out lol).
B
43
S
21
G
9
Posts: 141
Reputation: 8,926


Return to How do I....?

Who is online

Users browsing this forum: blissfulwizard, DevinMurray, RobertMKD and 15 guests