OR expression (|) Not Working Please help

  • [attachment=0:2zzkz3dg][/attachment:2zzkz3dg]

    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

  • 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

  • Hi brhodes8 - just as 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.

  • [attachment=0:32q39rj2][/attachment:32q39rj2]

    hundredfold

    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"

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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"

  • 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

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

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

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