0 Favourites

Unexpected behavior mixing Or/Else

  • Problem Description

    In the attached example I am selecting text objects based on an "OR" to set the text one way. There is an "ELSE" below the "OR" which should catch all remaining text objects and set those to something different.

    If you adjust the code to a set of individual events (IE no OR or ELSE) then it works fine.

    Any help, suggestions etc appreciated.

    Attach a Capx

    Done, see attachment.

    Description of Capx

    Simply has 6 text objects, each has a single instance variable, called NumIn which is set to a random number (0 to 3) when a mouse key is pressed. Firstly this random number is placed in the text box, then a different message depending on whether the number is in 1,3 or in 0,2.

    Steps to Reproduce Bug

    • Run capx
    • click any mouse key
    • Observe that not all text boxes get the result message.

    Observed Result

    Not all text objects are being selected in the OR/ELSE block, some remain unset. The ELSE condition seems to get ignored.

    I am not sure why this is happening, possibly the else is not acting on both parts of the or?

    Expected Result

    All text objects should get the result message.

    Affected Browsers

    • Chrome: (YES)
    • IE
    • Sorry, these are all I have installed just now

    Operating System and Service Pack

    Windows 8.1

    Construct 2 Version ID

    Beta r185

  • This looks to be related to the design of Else where it doesn't pick any objects, per the manual entry under Special conditions. Putting your code in a For each loop over the Text object - as a sub-event to the mouse click event - looks to give you the result you're looking for.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • So only if it does not get any objects that match the first condition(s) will it go to the else.

    Okay, thanks for clearing that up.

    Simple solution therefore is to put in two events one to test for 1,3 and the other for 0,2.

    I may put in a feature request for a 'pick else' or 'pick other' event to cover this.

  • Closing as won't fix, as documented "Else" really means "If the previous event did not run", and in this case it usually runs so the Else event never runs.

    Workaround: just use another event like "num = 0 or num = 2".

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
[BEHAVIOR] Chipmunk Physics
673 82,501
nelostic's avatar
nelostic
Unread hot topic
0 Favourites
[Behavior] LiteTween
672 169,877
manujorgo's avatar
manujorgo
Unread hot topic
564 105,210
rexrainbow's avatar
rexrainbow