How do I make AND and OR conditions mixed

0 favourites
From the Asset Store
25 Royalty free tracks from 16 genres including western, sci-fi, war, mythical and many more.
  • Hello,

    I'm developing a game, and I need to do some contion like this:

    if ((x = true OR y = true) AND z = true) then make this...

    How can I do this in a block of conditions. I tried, but if I convert the block to OR, then all condition is OR. I tried

    As the image I attached. I need conditions like this:

    (Mouse - On left button Clicked on btnAdelante

    OR

    Is touching btnAdelante)

    AND (Variable NroInstruccion = "a").

    Also, I'd like to know if it's possible a condition with the touch as the click on the mouse (I mean, not "is touching", just "touched" as a tap with the finger).

    Thank you very much!

  • use subevents to separate the ANDs and ORs

    if x = true

    OR

    y = true

    (subevent)--z = true | then your action

    and the touch thing, yeah, just look at all the choices that come up when you choose touch..

    there's tap, there's touch start, there's on object touched, etc... (the ones with green arrows are triggers, like the mouse click)

  • That works for logic but it won't work in this case because of the triggers. You can't do an expression like the one you're after involving triggers, with subevents. Just have separate events calling the same Function.

    edit: e.g.

    --------------

    Mouse: On Left button Clicked onbtnAdelante -> Function("func")

    --------------

    Touch: Is touching btnAdelante

    System: NroInstruccion = "a" -> Function("func")

    --------------

    Also your first example

    ((x = true OR y = true) AND z = true)

    is different to your second example, which translates to

    (x = true) OR (y = true and z = true)

    You could do the first but not the second.

    BTW you can also use the System: Compare expression like

    System: ((x = 1) | (y = 1 & z = 1)) = 1

    if your expression involves variables and not triggers.

    tl;dr If your first logic example is what you're after, subevents will work, otherwise they won't

  • use subevents to separate the ANDs and ORs

    if x = true

    OR

    y = true

    (subevent)--z = true | then your action

    and the touch thing, yeah, just look at all the choices that come up when you choose touch..

    there's tap, there's touch start, there's on object touched, etc... (the ones with green arrows are triggers, like the mouse click)

    Excellent!, thank you very much!, very useful... thanks for sharing your knowledge!.

  • That works for logic but it won't work in this case because of the triggers. You can't do an expression like the one you're after involving triggers, with subevents. Just have separate events calling the same Function.

    edit: e.g.

    --------------

    Mouse: On Left button Clicked onbtnAdelante -> Function("func")

    --------------

    Touch: Is touching btnAdelante

    System: NroInstruccion = "a" -> Function("func")

    --------------

    Also your first example

    ((x = true OR y = true) AND z = true)

    is different to your second example, which translates to

    (x = true) OR (y = true and z = true)

    You could do the first but not the second.

    BTW you can also use the System: Compare expression like

    System: ((x = 1) | (y = 1 & z = 1)) = 1

    if your expression involves variables and not triggers.

    tl;dr If your first logic example is what you're after, subevents will work, otherwise they won't

    Great!, thank you very much for your clarification!...

  • Well... I made what the attached image shows, but it doesn't work well...

    I don't understand well. The first action works perfect, but the second one is not working...).

  • I'm sorry, I made a mistake. I correct it but still there's an error I don't understand.

    The action i conditions 1,2 work goog, but 3,4 doesn't work (the animation doesn't change).

  • are you changing the variable to "b" and not just the animation?

    alternatively, you can check the animation itself instead of using a variable.

  • Yeah!, you're right!. Thank you very much, but still I have a problem...

    it seems if I click once all the actions are executed, so I only see the final action result (I click the btnAdelante and then I see the last animation, as if the three actions were performed at one click instead of three clicks...)

    Why this could be happening ?...

  • I change all for these conditions... but if I click the btnAdelante button I immediately see the Menu Layer (which is supposed to be at the four clic I made)

  • I just explained this same issue over here:

    See if that helps.

  • Sooo you don't need to repeat the Mouse and Touch events. Just have it once, and then as a subevent:

    ----------------------------------------

    Instruccio...: Is animation "a" playing -> Instrucci...: Set animation to "b" (play from current frame)

    Else

    Instruccio...: Is animation "b" playing -> Instrucci...: Set animation to "c" (play from current frame)

    Else

    ...

    -----------------------------------------

    That's ONE step better but you can still do better. (hint: try naming your animations with digits 1, 2, 3 instead of letters..)

    Edit: I just saw BH's post, I'm sure whatever it is will do the job

  • Sooo you don't need to repeat the Mouse and Touch events. Just have it once, and then as a subevent:

    ----------------------------------------

    Instruccio...: Is animation "a" playing -> Instrucci...: Set animation to "b" (play from current frame)

    Else

    Instruccio...: Is animation "b" playing -> Instrucci...: Set animation to "c" (play from current frame)

    Else

    ...

    -----------------------------------------

    That's ONE step better but you can still do better. (hint: try naming your animations with digits 1, 2, 3 instead of letters..)

    Edit: I just saw BH's post, I'm sure whatever it is will do the job

    Hello Codah,

    OK I try to change the name of the animations but if I type 1 it changes to the letter (I guess numbers aren't valid names).

    Then I put elses as you recommended but still the same... I click the sprite and it goes to the last animation immediately.

    I'm reading the BH's post too trying to solve and understand this problem...

    thank you very much both!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • These are my new conditions...

  • Can you just post the CAPX. It makes life much easier.

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