Unexpected behavior mixing Or/Else

Bugs will be moved here once resolved.

Post » Mon Oct 27, 2014 12:47 pm

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
You do not have the required permissions to view the files attached to this post.
B
16
S
4
Posts: 35
Reputation: 2,393

Post » Mon Oct 27, 2014 1:29 pm

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.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,116

Post » Mon Oct 27, 2014 2:42 pm

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.
B
16
S
4
Posts: 35
Reputation: 2,393

Post » Wed Oct 29, 2014 4:31 pm

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".
Scirra Founder
B
397
S
236
G
88
Posts: 24,389
Reputation: 194,448


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 3 guests