The OR operator is not working!

0 favourites
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • Ashley

    Confirmed. The expression editor won't take an expression like

    "red"="red"

    It says "type mismatch, = does not work with 'integer' and 'string' (use & to build strings)"

    dcrew

    You can use a private variable to combine picking across events to do an "or".

    http://dl.dropbox.com/u/5426011/examples%208/or_example.capx

    Does no one understand what I asked for? I don't want multiple events, for example: take your capx and the event "Is animation 'Red' Playing?" rather than having it seperate I want: "Is animation 'Red' or 'Blue' or 'Green' or 'Purple' Playing?" for reasons I do not feel the need to explain. I'm happy to wait till Tom and Ashley fix this <img src="smileys/smiley1.gif" border="0" align="middle">

  • Does no one understand what I asked for? I don't want multiple events, for example: take your capx and the event "Is animation 'Red' Playing?" rather than having it seperate I want: "Is animation 'Red' or 'Blue' or 'Green' or 'Purple' Playing?" for reasons I do not feel the need to explain.

    I know you won't listen, because I tried to explain it two times. We did understand, but the simple fact is, "or" in a programming language does not work like "or" in a spoken language.

    While you can say, "Is the apple's color 'green', or 'red', or 'orange'?", and everyone will understand you, for the logic of a programming language you have to phrase, "Is the apple's color 'green', or is the apple's color 'red', or is the apple's color 'orange'?", which is a tiny little difference for us humans, but a huge one for logical operators.

    The first one will look to Construct like so: "Is the apple's color 'TRUE', or 'TRUE', or 'TRUE' "

    Now 'or' returns true if any of the elements result to true. They all result to true, no matter what the real color's name is, because they are non-empty strings, so the result will always be 'TRUE'.

    What you need is a way to get the boolean 'TRUE' only if the apple's color is either of the three color names and 'FALSE' in all other cases.

    That's why the second one is so important. There you have three evaluations and every single one will only be true, if the apple's color matches that name. Let's say, the current color name is 'green', then the second one will look to Construct like so: " 'TRUE', or 'FALSE', or 'FALSE' "

    That's important as soon as the real color of the apple does not match any of the three color names. Let's say, the color of the apple is 'purple'.

    First one will still read as: "Is the apple's color 'TRUE', or 'TRUE', or 'TRUE'" That will result to 'TRUE', so the event will be executed, although the apple does not have the correct color.

    Second one will read as: " 'FALSE', or 'FALSE', or 'FALSE' " That would result to 'FALSE', just as we expect it to be.

    As soon as the type mismatch issue is corrected by Ashley, you still have to phrase it the right way.

    Block.AnimationName = "Block1" | "Block3" | "Block13" | "Block14"

    will still not work (as I explained above). It is phrased wrong.

    Block.AnimationName = "Block1" | Block.AnimationName = "Block3" | Block.AnimationName = "Block13" | Block.AnimationName = "Block14"

    is the only way to make it work as you want it to behave.

  • tulamide

    Sorry, I misunderstood. Now I understand, thanks! And I don't mind waiting <img src="smileys/smiley17.gif" border="0" align="middle" />

  • Well, I've fixed two bugs for the next build now thanks to this thread - numbers aren't accepted to animation parameters, and the = operator works properly for strings. So hopefully it will be a little smoother in the next release :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Um even if they add a way to add multiple comparisons to or, that wont work with picking using the system compare. Also you have the possibility of triggering the action more than once.

  • Um even if they add a way to add multiple comparisons to or, that wont work with picking using the system compare. Also you have the possibility of triggering the action more than once.

    Block.AnimationName = "Block1" | Block.AnimationName = "Block3" | Block.AnimationName = "Block13" | Block.AnimationName = "Block14"

    Will return a value of 1 if any of those are correct.

  • Right, and then it goes to the next one.

    It's not a big deal, if you don't want it triggered more than once you can just add the trigger once while true as a sub event.

  • Right, and then it goes to the next one.

    It's not a big deal, if you don't want it triggered more than once you can just add the trigger once while true as a sub event.

    I know, As much as I'd love to explain my 2D rendering system I made, I'm not going to. Because it renders the world and every time it renders that event will run.. and so on.

  • For what it's worth, regarding the OR plug-in, there is no good way to dynamically define the number of expressions in a condition. After a number of PMs with Ashley, he convinced me it would be easier to wait for him to build it into C2, rather than try to code the clunky dynamic method I was working on.

    dcrew, I can add more conditions to the plug-in, i.e. an OR-3 with 3 expressions, an OR-4 with 4 expression, etc., if that would help you get by for now. Otherwise, we can just wait until it gets implemented (but not before families please! :D).

  • For what it's worth, regarding the OR plug-in, there is no good way to dynamically define the number of expressions in a condition. After a number of PMs with Ashley, he convinced me it would be easier to wait for him to build it into C2, rather than try to code the clunky dynamic method I was working on.

    dcrew, I can add more conditions to the plug-in, i.e. an OR-3 with 3 expressions, an OR-4 with 4 expression, etc., if that would help you get by for now. Otherwise, we can just wait until it gets implemented (but not before families please! :D).

    This is already solved, and Ashley already fixed it. I just do this now:

    <img src="http://screensnapr.com/e/EqI8xc.png" border="0" />

  • Sweet! Maybe I should retire the OR plug-in then. It had a short, sad life. <img src="smileys/smiley41.gif" border="0" align="middle" />

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