How do I use both "And" and "Or" in the same condition box?

Discussion and feedback on Construct 2

Post » Tue Jun 07, 2016 4:58 am

When selecting/deselecting the "or" block with conditions in an event block, you end up with either this:
  • On pressed Enter
  • Variable = 1
  • On Touched Object
    • Do stuff
or this:
  • On pressed Enter
    Or
  • Variable = 1
    Or
  • On Touched Object
    • Do stuff
Is there any possible way to get this?:
  • On pressed Enter
  • Variable = 1
    Or
  • On Touched Object
    • Do stuff
B
16
S
5
G
4
Posts: 29
Reputation: 3,100

Post » Tue Jun 07, 2016 5:12 am

I use a local variable to achieve this i.e:

On pressed Enter -and- Variable = 1 | LocalVar = 1
On Touched Object -or- LocalVar = 1 | Do stuff
B
38
S
16
G
6
Posts: 537
Reputation: 7,582

Post » Tue Jun 07, 2016 5:17 am

Use sub event to add an And block

+ On pressed Enter
-- +Variable = 1
-- Or
-- +On Touched Object
B
108
S
26
G
260
Posts: 4,435
Reputation: 146,193

Post » Tue Jun 07, 2016 5:26 am

@rexrainbow can't put triggers on sub-events..

I wouldn't use a local variable, either though. Best I can figure, just do it in two events.

you could put the triggers together with the OR and then subevent the variable plus a check for which-- yeah, see.. just use two events..
B
86
S
43
G
71
Posts: 601
Reputation: 43,619

Post » Tue Jun 07, 2016 5:27 am

@ErekT Okay, that's a pretty simple workaround. Thanks! ^_^

I hope Ashley adds some sort of "Condition Bracket" in a later update, to bypass the need for extra variables. Is there a way, or place where, I can suggest a feature request for this?

@rexrainbow What you're suggesting, mathematically, is:

"On pressed Enter AND (Variable = 1 OR On Touched Object)"

I'm looking for "(On pressed Enter AND Variable = 1) OR On Touched Object"
B
16
S
5
G
4
Posts: 29
Reputation: 3,100

Post » Tue Jun 07, 2016 5:52 am

@spacedoubt

Uh, you are right. I miss it.
Then I will split these two trigger and add another function trigger:

+ On pressed Enter
+ Variable = 1
- call function "xx"

+ On Touched Object
- call function "xx"
B
108
S
26
G
260
Posts: 4,435
Reputation: 146,193

Post » Tue Jun 07, 2016 5:58 am

rexrainbow wrote:+ On pressed Enter
+ Variable = 1
- call function "xx"

+ On Touched Object
- call function "xx"


Even better! Just implemented this and it works great!
B
16
S
5
G
4
Posts: 29
Reputation: 3,100


Return to Construct 2 General

Who is online

Users browsing this forum: 99Instances2Go, chleep and 1 guest