Or bug

0 favourites
  • 11 posts
From the Asset Store
Match same tiles with each other as fast as you can and earn more score during a limited time!
  • Problem Description

    ____ When you have an 'Or' block with a condition <> "" and that object equals "", and there are other conditions that are true, the subevents don't fire ____

    Attach a Capx

    ____ [attachment=1:35fh9o8u][/attachment:35fh9o8u] ____

    Description of Capx

    ____ [attachment=0:35fh9o8u][/attachment:35fh9o8u] ____

    Steps to Reproduce Bug

    • make 'Or' block with some true conditions, and one condition that is false ( <> "" )
    • add subevent that checks if object is invisible(true), with action to make visible. Observed Result ____ The subevent doesn't fire. ____ Expected Result ____ The object should be made visible ____ Affected Browsers
      • Chrome: (YES)
      • FireFox: (YES)
      • Internet Explorer: (YES/untested)

    Operating System and Service Pack

    ____ Win Vista sp2 ____

    Construct 2 Version ID

    ____ r190 ____

  • Umm, the capx you provided is working fine, the sub-event is firing...what is the problem here?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The sprite2 isn't made visible.

    What version are you using TiAm?

    I'm using r190.

  • Okay, this is strange...I'm almost sure it was working before...but now it isn't. Hmmm...

  • The second condition is asking C2 to PICK the Sprite2 objects where textVar <> "", of which there are none, so none are picked by the sub-event. You need to add "Pick all Sprite2" to event 3 to get the result you want.

  • that's fine, but shouldn't this work?

    [attachment=0:2t5hor1a][/attachment:2t5hor1a]

    If you pick a sprite2, it should keep that picked.

    So there's an issue going on here.

  • another thing.. if it is an 'Or' block, if it finds one condition true, there is no need to check the following conditions- so why even try to pick sprite2 at all during the 'Or' block? This would be improper if it has to check all the conditions.

    edit: to expand upon the previous post.. say I pick some sprite2 that match a certain conditions, and then do the 'Or', and there are some sprite2 that haven't been picked previously(and thus should be left out of the 'Or'), then it should only check the ones currently picked(it shouldn't have to check all the sprite2 during the 'Or').

  • I realized I could do the same thing a different way, so in-case anyone is wondering, here is the workaround to the problem:

    [attachment=0:kwehza8u][/attachment:kwehza8u]

    I don't really understand why the other way doesn't work, and I'm unsure if this workaround is viable in all situations, but for some it might be.

  • that's fine, but shouldn't this work?

    [attachment=0:18nax3pc][/attachment:18nax3pc]

    If you pick a sprite2, it should keep that picked.

    So there's an issue going on here.

    Like blackhornet said, there are 0 Sprite2 instances picked after event 2, so filtering these further with the 'is visible' check does nothing (well not nothing, it causes you to have 0 picked instances). You need a pick all (presumably followed by a 'pick instance 0') before the Is visible check.

    The reason your last example works is because you didn't change the picking after the initial pick instance 0, so it's still picked further down.

    Regarding your question about evaluation of OR conditions, from the manual under 'or blocks':

    [quote:18nax3pc]Note that because OR blocks run if any condition is true, it's possible the event will still run if some conditions were false and did not pick any instances. In this case the actions will still run, but possibly with zero instances picked for any objects where no instances met the condition. If any actions are run for objects with no instances picked, nothing happens.

  • Alright.

    Well, I still think it is illogical based on common sense- I can't see where the advantage is in that. I'd be interested in knowing why it is better that way compared to what I would expect it to do.

    Why pick 0 of them if it didn't need to pick any in the first place? Seems like wasted processing.

  • Closing as not a bug, it is working correctly. The confusing thing about OR blocks is they can pick 0 instances for a condition. In this case it picks no "Sprite2" instances, since no Sprite2 instances meet the condition "textvar is not empty", but the event runs anyway because a previous condition was true and OR blocks only need one condition to be true to run. The problem is that you were expecting the wrong thing.

    Look at it this way: if 'Sprite2' *was* set to visible even though its textvar is empty, it would be contradicting the previous condition that checked its textvar was not empty.

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