How do I use OR in a condition?

0 favourites
  • 9 posts
  • I thought I knew how to use | in the conditions. But seems like I have forgot, made this small example and thought it would also trigger with the OR-statement? But as you see it dous not. The breakpoint never fires

    So, how should I state it? :)

    Tagged:

  • This is a common mistake: "A"|"B" evaluates to 1 (meaning true, because one of the values counted as "true"), so you are actually comparing TEST = 1.

    You probably want an OR block instead. See How events work.

  • Ah yea, with OR block it will work fine. Thanks!

    In my case, the variable can have 200 different values (it is the country of the player, retrieved from the internet connection), and based on the variable they should set the region of the server. so maybe 20 values should go into one action, 20 others into action2 etc. So I thought I could just do them in one go like my example.. :)

    With OR blocks I guess it will be 200 OR blocks, devided into 10 different events then.. Maybe I will think of some other solution.. hmm..

  • If you need to compare if a value matches any of a large number of other values, put them all in an Array, and use the Contains value condition.

  • or put the values in a string with a delimiter and use TokenAt

  • If you need to compare if a value matches any of a large number of other values, put them all in an Array, and use the Contains value condition.

    I am not super familiar with arrays and json stuff, but this solution worked for me. Is this basically the events you meant?

  • You could also have a OR block for both checks, since the result seems to be the same.

    europe contains value country
    OR southamerica contains value country
    ----Toggle verify
    

    Cheers

  • You could also have a OR block for both checks, since the result seems to be the same.

    > europe contains value country
    OR southamerica contains value country
    ----Toggle verify
    

    Cheers

    No, they are supposed to do different things (log on to different servers). the toggle is just for the breakpoint, to see if they fire :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I see... :)

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