OR condition

This forum is currently in read-only mode.
  • I have never used OR and ELSE conditions in my projects. Usually I get runtime errors, but I think it is a waste of resources. So, here is an example, where I have insert an OR condition, but gives me a runtime error. What is wrong?

    <img src="http://dl.dropbox.com/u/472186/Construct/Forums/Irudiak/or.jpg">

  • Using OR will eventually cause problems that make your game crash. It is considered unstable and should be avoided imo. I only use OR very rarely and only in simple events without branching. And even then only for quickly testing stuff.

    So instead of using OR you could just check if sCamera-isMoving + rLight-isMoving is greater than 0.

    Oh, but don't be afraid to use the ELSE condition. That one is safe and very useful.

  • [quote:kgez78w6]So instead of using OR you could just check if sCamera-isMoving + rLight-isMoving is greater than 0.

    Thanks, simple and clean solution

  • ELSE condition looks that it does not work properly with sub-events inside.

  • ELSE condition looks that it does not work properly with sub-events inside.

    ELSE had issues until 0.99.91

    Since then it works, at least for me.

    Using OR will eventually cause problems that make your game crash. It is considered unstable and should be avoided imo. I only use OR very rarely and only in simple events without branching. And even then only for quickly testing stuff.

    Is this so? I couldn't read about it. Do you have a link or more info about what exactly is a problem with using OR? I for one do use it more and more, and had no issues so far. But I admit, I don't use it in overcomplicated structures. But I use it with branching also, and couldn't report any problems so far.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I also had issues with OR. For ex.

    If x greater or equal 1

    or

    if x lower or equal -1

    It could work or not, it's really unstable. And when you have too much OR in one event. Later I've decided to change it on structure:

    if xxx - then do xxx

    else if xxy - do xxy

    else if xyx - do xyx

    else if...

    and so on.

  • I also had issues with OR. For ex.

    If x greater or equal 1

    or

    if x lower or equal -1

    It could work or not, it's really unstable. And when you have too much OR in one event. Later I've decided to change it on structure:

    if xxx - then do xxx

    else if xxy - do xxy

    else if xyx - do xyx

    else if...

    and so on.

    I see, thank you. So it seems that OR'ed comparisons with numbers are working unreliable? I will test it. Would be very frustrating to debug if it happens to a progressed project. Thanks for the example!

  • So it seems that OR'ed comparisons with numbers are working unreliable?

    I've got issues even with string comparsion, imo it's about OR in all cases - unstableness)

  • I've made a post about the possible problem with or:

    http://www.scirra.com/forum/viewtopic.php?f=3&t=7428

  • Just thought that I'd point out a possible workaround to using the OR condition. I've found that most anything that I've wanted to use it for can be done just as well with the system condition Evaluate, using the OR operator in an expression form. Like so:

    + System: global('x') = 2 or global('x') = 5

    -> Do something...

    It has not caused me any problems, and allows for more complex logical tests in less space. Parentheses and the AND operator can be used to group parts of the expressions as appropriate, too. Perhaps something like so:

    + System: (global('x') = 2 and global('y') > 6) or (global('x') = 5 and global('y') <= 6)

    -> Do something...

    I've gone to this every time that the OR condition seemed to be causing me problems, and it worked.

  • Sigh, I didn't know it was unstable.

    This might be the cause of the weird crashes on my first completed game

    I'll be sure to avoid it in my current one.

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