How do I code this?

0 favourites
  • 8 posts
From the Asset Store
Two levels with two sistem Wave. with Source-code (.c3p) + HTML5 Exported.
  • 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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Check the instance variables animation frame... Then add a sub event to check the next IV

  • 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?

  • 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...
  • 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!

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

    https://goo.gl/JAUtxv

  • 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 !

  • RamPackWobble

    Thanks heaps for the example, It does exactly what I need (but I would have never figured that out lol).

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)