OR expression (|) Not Working Please help

Discussion and feedback on Construct 2

Post » Tue Nov 25, 2014 6:26 pm

construct.png


Hello!
I'm trying to simply compare the value at an array and if the value Array.at(1) = 1 or 2 to change the text to working. However, when I change the value of the array.at(1) = 2, it does not change the text. But it does change the text when array.at(1) = 1. Please let me know what I'm doing wrong with my or expression. I attached a picture of my very simplified event list.
Thank you,
Bryan Rhodes
You do not have the required permissions to view the files attached to this post.
B
4
Posts: 20
Reputation: 240

Post » Tue Nov 25, 2014 6:36 pm

Right click on the event and then "make OR block". Then do as this:

Array: Value at 1=1

OR

Array: Value at 1=2
B
37
S
5
G
2
Posts: 46
Reputation: 3,854

Post » Tue Nov 25, 2014 6:51 pm

Hi @brhodes8 - just as @CleitonEldron says, but make sure you click the event just to the left of the array icon otherwise you won't be offered the option he mentioned. Then right-click again to add an extra condition.

btw... you do a similar thing for AND commands but just untick the "make OR block" option.
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Tue Nov 25, 2014 7:11 pm

construct2.png


@hundredfold @CleitonEldron
Thank you for the help and quick replies. However Maybe i simplified the event list too much. I know about the OR block but it won't help as there will be multiple conditions. Please see new attached picture to understand why the OR block wont work.

The logical path should be IF Array.at(0)=2 AND Array.at(1)= 1 OR 2 then set text to "working"
You do not have the required permissions to view the files attached to this post.
B
4
Posts: 20
Reputation: 240

Post » Tue Nov 25, 2014 7:15 pm

Hi @brhodes8 - you can nest those conditions inside each other to achieve what you want.

So you'd get something like this:

Array.at(0)=2
----- Array.at(1)= 1
----- OR
----- Array.at(1)=2 then set text to "working"
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Tue Nov 25, 2014 7:17 pm

If array.at(0)=2
-> subevent
array.at(1)=1 | array.at(1)=2

edit:
@hundredfold
You ninja. haha. Guess I read the posts too slow, you beat me to the answer xD
Last edited by Tylermon on Tue Nov 25, 2014 7:20 pm, edited 1 time in total.
B
28
S
8
G
1
Posts: 226
Reputation: 2,865

Post » Tue Nov 25, 2014 7:18 pm

You kinda drag and drop to the right to create the nesting arrangement and it sometimes doesn't quite do as you'd like/expect but you should get used to it after a while.
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Wed Nov 26, 2014 9:39 am

You could do System: 0 < array.at(1) < 3
:)
Actually I'll have to remember to use this more often myself. I know it's really meant for decimal values but it's a nice shortcut.

BTW you could merge lines 2, 3, 4 into one line and 5, 6, 7 into one line as well.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596


Return to Construct 2 General

Who is online

Users browsing this forum: Artpunk, BadMario, jobel and 2 guests