Robust way of using "or" block

0 favourites
  • 13 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • At this moment when using an "or" block in the event sheet, it is possible to specify only 1 condition before it is seperated by the "or" statement.

    So If I have 3 IF's in an event, and add an "or" all three are seperated automatically moving each IF into a different "group" followed by or, which can be really annoying.

    Its not possible to have little groups of IF's and select manually which IF's are divided by the "or" statements. This produces problems when I want to use an ELSE IF statement when using the "or blocks", and need to end with an ELSE statement. The problem is when I have 2 more events/conditions with 3 or more IF statements, then its not possible to introduce one Else IF, but two need to be ELSE statements which renders one of them not functional.

    So to present what I mean more visually:

    What I would like:

    IF x=z

    and

    IF x=b

    or

    IF x=c

    What I am getting automatically:

    IF x=z

    or

    IF x=b

    or

    IF x=c

    Now the above example is just for example sakes and doesnt reflect the exact IF statemets I have, which cannot be solved any other simpler way than using the or block with robust function implemented. I end up having to work my way in circles to try and solve this issue through additional variables and the likes.

    If its not possible to pick manually which IF statements should be divided by "or" statements, I strongly believe it should be as this feature would help tons when implemented.

  • I guess using a local variable for this is the easiest, like in this thread:

  • LittleStain

    Well as I have so many variables already the best solution would be to use and and or block like I stated above. It would be ten times faster than adding another variable and looking for it, and yet making the variable list even longer, which would make searching for other variables down the line even longer because of the one additional variable.

    I know there are other ways around, like I had written but adding variables quickly stops being a good alternative as the lists get longer.

  • LittleStain

    Well as I have so many variables already the best solution would be to use and and or block like I stated above. It would be ten times faster than adding another variable and looking for it, and yet making the variable list even longer, which would make searching for other variables down the line even longer because of the one additional variable.

    I know there are other ways around, like I had written but adding variables quickly stops being a good alternative as the lists get longer.

    I am talking about local variables, not global..

    There is usually no reason to have a very long list of global variables, because most of them can be local variables or instance variables or array-values or dictionary-object values..

  • LittleStain

    I still have a long list of variables both global and local when I search for variables to add to the "compare to" event. Is there a way to filter only local variables so that only these would be shown when looking for variables? The fact that the icon is different for local/global does not cut it for me sadly.

  • Ok, strange..

    Local variables can only be accessed in their scope, so they shouldn't show up in the dropdownbox if they aren't available..

    Sounds like the way you have set up your variables might not be the best way..

  • LittleStain - Local variables are indeed shown only when they are within their scope but what I am trying to tell you that all the other global variables are shown there too, besides the local variables. That does not help as the list is getting longer. This has nothing to do with how I set up my variables I dont think, only how C2 displays the lists of variables - both global and local are in the same bag when looking for local (not when looking for global), unless indeed there is something wrong with my workflow, thus I am trying to find out.

    Edit: To illustrate:

    What happens:

    Looking for local variables - list:

    Global variables x 1000

    Local varibales x 10

    Looking for global variables - list:

    Global variables x 1000

    What I would like:

    Looking for local variables - list:

    Local varibales x 10 -----> only - no global variables available to choose --> makes list waaaay shorter

    Looking for global variables - list:

    Global variables x 1000

  • LittleStain - Local variables are indeed shown only when they are within their scope but what I am trying to tell you that all the other global variables are shown there too, besides the local variables. That does not help as the list is getting longer. This has nothing to do with how I set up my variables I dont think, only how C2 displays the lists of variables - both global and local are in the same bag when looking for local (not when looking for global), unless indeed there is something wrong with my workflow, thus I am trying to find out.

    I'm just wondering why your list is so long..

    Shouldn't be nescessary..

    Like I said, there are other ways to keep global values, which as you see now, you cou'd benefit from..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This has been requested before. Another solution would be to use the system->"compare" or "pick by comparison" with one expression like:

    (x=z) & (x=b) | (x=c)[/code:11qwzyad]
  • What I would like:

    IF x=z

    and

    IF x=b

    or

    IF x=c

    Well you can't simply mix "or" and "and" inside a single event, because there's actually two way to interpret this:

    • "A and (B-or-C)"
    • "(A-and-B) or C",

    If you're looking for the first one, simply put one part into an event, and the second part into a sub-event like this :

    --> If A

    _____ --> If B

    ___________-or-

    ___________C

    If you're looking for the second one, it's gonna be a little more tricky indeed. And local variable seems like the best way to work around that indeed:

  • LittleStain - Local variables are indeed shown only when they are within their scope but what I am trying to tell you that all the other global variables are shown there too, besides the local variables. That does not help as the list is getting longer. This has nothing to do with how I set up my variables I dont think, only how C2 displays the lists of variables - both global and local are in the same bag when looking for local (not when looking for global), unless indeed there is something wrong with my workflow, thus I am trying to find out.

    Edit: To illustrate:

    What happens:

    Looking for local variables - list:

    Global variables x 1000

    Local varibales x 10

    Looking for global variables - list:

    Global variables x 1000

    What I would like:

    Looking for local variables - list:

    Local varibales x 10 -----> only - no global variables available to choose --> makes list waaaay shorter

    Looking for global variables - list:

    Global variables x 1000

    I'm sorry..

    1000 global variables?

    I know this is meant as an exaggeration, but even 100 would sound ridiculous..

  • LittleStain

    It is shown to prove my point, please dont focus on proportions in this situation.

    Doesnt matter if its 1000 or 100, 100 is indeed a lot too. As is 50. Besides blowing up things out of proportion helps visualise the problem as you surely know.

    Hmm... alrighty I will check out your link in detail, but still I think that adding option to the "or" block to choose where to put or and where to put and would be great, a real time saver.

    R0J0hound

    If it was requested before, its a shame that this has not been added

    Hmm, Im entering virgin territory with your statement/piece of code I need to look into this

    Estecka

    Well no I dont think so.

    WIth:

    IF x=z

    and

    IF x=b

    or

    IF x=c

    There is only 1 explanation: If x=z and b, or IF x=c, but used with an "or" and an "and" block. How can this be interpreted differently?

    As for the first or second, no there is no first or second, I would like the option with or/and not with or/or like it is now automatically avaliable.

  • There is only 1 explanation: If x=z and b, or IF x=c, but used with an "or" and an "and" block. How can this be interpreted differently?

    Well again, I could as well interpret it as IF x=z, and IF x=b or x=c.

    Unless there is a programming rule I don't know that tells which operations must be performed first? (Like in math with multiplications and additions?)

    LittleStain - Local variables are indeed shown only when they are within their scope but what I am trying to tell you that all the other global variables are shown there too, besides the local variables. That does not help as the list is getting longer.

    If you absolutely need this many global variables, one thing you could consider is turning some of them to instance variables.

    As an example, when I needed to manage the "hive mind" of certains AIs, many of the "global" variable I used for them were in fact instances variables of a single dictionary named Hive. These still work the same way as global variables except they don't appear under the system's list.

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