[206] Or block does not trigger even if one is true

Bugs will be moved here once resolved.

Post » Fri Aug 07, 2015 11:25 pm

Problem Description
Or Block does not always function as expected

Attach a Capx
https://www.dropbox.com/s/gg3j2vxm6lzvv ... .capx?dl=0

Description of Capx
In this demo, an or block checks conditions based on a global variable and an object instance variable. While one of the conditions of an or block is true, the event does not fire. If the second condition is true, the block will fire, but the first condition seems ignored.

Steps to Reproduce Bug
  • Create an object (tested this with sprite in a group and Text object)
  • Assign a variable to that object
  • Create a global variable
  • Make an or block testing the global variable and the object's variable.
  • Set the global variable check to be true and the object's variable to be false.
  • Run the project and observe that the event does not fire.

Observed Result
Event does not fire.

Expected Result
Event should fire.

Affected Browsers
  • Chrome: YES
  • FireFox: UNTESTED
  • Internet Explorer: YES

Operating System and Service Pack
Win7 SP1

Construct 2 Version ID
v206

Related thread
viewtopic.php?t=151494
B
10
S
2
G
2
Posts: 73
Reputation: 1,044

Post » Fri Aug 07, 2015 11:47 pm

But it does fire. Add a second (different) Text object and set it to "was met" right under the first Text object. It gets set. The problem is your second part of the OR gets run but picks nothing - so there is no Text object to set at event 3.

This is a side effect of C2 both checking and picking at the same time. You get these odd side effects. You need to change you logic to account for this.
ImageImageImage
B
71
S
21
G
231
Posts: 3,691
Reputation: 129,358

Post » Sat Aug 08, 2015 2:57 am

So how do I check the instance variable without changing the picked object?

Edit: I replaced it with compare to variables "Variable = 1" and it seems to work.
B
10
S
2
G
2
Posts: 73
Reputation: 1,044

Post » Mon Aug 17, 2015 12:52 pm

Closing as not a bug. It is working correctly.

Since one of the conditions in the OR block is true (the global variable check), the event runs. However it still picks all instances according to if they met the condition. Since no "Text" instances meet the condition "Is Variable1", the event runs with zero Text objects picked. Therefore despite the fact the event runs the "Set text" action has no effect. Note that if it did run, that would contradict the condition, allowing an action to run for an object that did not meet one of the event's conditions.
Scirra Founder
B
395
S
232
G
88
Posts: 24,371
Reputation: 193,762


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 2 guests