How do I make AND and OR conditions mixed

Just started using Construct 2? Post your questions here

Post » Thu Oct 16, 2014 4:24 am

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!
You do not have the required permissions to view the files attached to this post.
B
21
S
3
G
2
Posts: 86
Reputation: 2,262

Post » Thu Oct 16, 2014 4:38 am

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)
B
86
S
43
G
71
Posts: 601
Reputation: 43,619

Post » Thu Oct 16, 2014 5:22 am

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
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Thu Oct 16, 2014 2:52 pm

spacedoubt wrote: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!.
B
21
S
3
G
2
Posts: 86
Reputation: 2,262

Post » Thu Oct 16, 2014 2:55 pm

codah wrote: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!... :)
B
21
S
3
G
2
Posts: 86
Reputation: 2,262

Post » Thu Oct 16, 2014 5:14 pm

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...).
You do not have the required permissions to view the files attached to this post.
B
21
S
3
G
2
Posts: 86
Reputation: 2,262

Post » Thu Oct 16, 2014 5:22 pm

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).
You do not have the required permissions to view the files attached to this post.
B
21
S
3
G
2
Posts: 86
Reputation: 2,262

Post » Thu Oct 16, 2014 5:23 pm

are you changing the variable to "b" and not just the animation?
alternatively, you can check the animation itself instead of using a variable.
B
86
S
43
G
71
Posts: 601
Reputation: 43,619

Post » Thu Oct 16, 2014 5:42 pm

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 ?...
B
21
S
3
G
2
Posts: 86
Reputation: 2,262

Post » Thu Oct 16, 2014 5:45 pm

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)
You do not have the required permissions to view the files attached to this post.
B
21
S
3
G
2
Posts: 86
Reputation: 2,262

Next

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests