How do I use | in globalvariable = stringa or b or c?

0 favourites
  • 6 posts
  • object1 on collision object2 ----------- destroy object1

    --------- globalvariable1="a"|"b"|"c" ------- subtract 3 from globalvariable2

    do i need parenthesis somewhere in my subevent? around all of it? or each individual set of ""?

  • Try Construct 3

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

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

    object1 on collision object2 ----------- destroy object1

    --------- globalvariable1="a"|globalvariable1="b"|globalvariable1="c"=1 ------- subtract 3 from globalvariable2

  • A regexvariant would be

    test regex

    string: globalvariable1

    regex: "^[abc]$"

    flags: ""

    If you need to check for variable contents (a not being a string, but variable name), then the variant without regex will be easier.

  • Bear with me, I don't use construct as often as I would like....

    Try:

    object1 on collision object2 ----------- destroy object1

    --------- globalvariable1="a"|globalvariable1="b"|globalvariable1="c"=1 ------- subtract 3 from globalvariable2

    Is there a way to do a | in the midst of comparing global variables? I just see a drop down that I can't edit other than choosing one. If my understanding is not lacking, I would have to do each global variable= "whateverletter" as a separate sub event and that is what I was attempting to avoid. Eventually there will be 18 different possible values for globalvariable1 in this case (that mix and match combinations of 1 and 5), and 8 subevents already, each with another condition attached that is similar to the prior compare global variable, if I get it the way that I want. And this process will then need to be done an additional 18 times.

    A regexvariant would be

    test regex

    string: globalvariable1

    regex: "^[abc]$"

    flags: ""

    If you need to check for variable contents (a not being a string, but variable name), then the variant without regex will be easier.

    I didn't know that test regex was a thing, this may work, though it was not what I originally was hoping for. I'll have to do some more research, but I mostly would still Just like to know the proper format for finding comparing a global variable to multiple possibilities in text form

    if I'm not being clear, when I'm at this stage

    variable: globalvariable1

    comparison: =

    value: this is the part I don't know how to put multiple text possibilities separated by |

  • Second value 1=true ;0=false

  • awesome thanks so much everyone! I understand now!

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