Odd Behavior with Or block

Discussion and feedback on Construct 2

Post » Fri Jun 26, 2015 6:53 pm

I had a pickup object on which I wanted to call a function "pickup()" if the player rolled over it with the mouse OR after an on timer event on that object. I set up both events and tested them. They both worked:

Image

When I combined them into an OR block, it would only work on the first event in the block. If I switched the order, the first would always work, but it would never trigger if the second event in the Or block was triggered.

Image

Is there something obvious I'm missing here? Are there any known issues with Or blocks? Or is checking for a cursor over an object somehow incompatible with checking for an on timer event? Both seem impossible, yet... it doesn't work. I have Or blocks all over the place that work, so I'm pretty sure it's set up properly...
B
8
S
2
G
1
Posts: 37
Reputation: 1,476

Post » Fri Jun 26, 2015 7:21 pm

Timer is a Trigger. You can not combine it like regular events. Given that you just call a function anyway, there is no need to use an OR, just separate the events.
ImageImageImage
B
71
S
22
G
247
Posts: 3,756
Reputation: 137,558

Post » Fri Jun 26, 2015 7:36 pm

Interesting. Is there a list of "triggers"? Thanks for the quick reply!
B
8
S
2
G
1
Posts: 37
Reputation: 1,476

Post » Fri Jun 26, 2015 7:46 pm

Anything with a green arrow, typically named "On XXX".
ImageImageImage
B
71
S
22
G
247
Posts: 3,756
Reputation: 137,558

Post » Fri Jun 26, 2015 8:28 pm

blackhornet wrote:Timer is a Trigger. You can not combine it like regular events. Given that you just call a function anyway, there is no need to use an OR, just separate the events.

I believe that's not true. The trigger should work in this situation with regular events like expected. The manual entry for OR blocks even use triggers as examples.

I suggest posting a capx with a simple reproduction so it's possible to tell if it's really a bug in C2 or some other events are interfering with your project's logic.
Scirra Employee
B
155
S
53
G
17
Posts: 710
Reputation: 17,875

Post » Fri Jun 26, 2015 8:55 pm

Oh weird. It does seem like something that should work. It's just a check.

I'd rather not post my entire game capx. It seems an easy thing to reproduce in a couple of steps? The only behavior on my "cigarette" object is the timer. Both events work fine alone or if they are the first event in the "or" block.
B
8
S
2
G
1
Posts: 37
Reputation: 1,476

Post » Fri Jun 26, 2015 9:39 pm

Manual: "Also note normally you can only put one trigger in an event, but you can put multiple triggers in an 'Or' block, and the event will run if any of triggers run."

It depends on the usage. Triggers run outside of the normal event loop, so you do have to be careful of combining with other events.
ImageImageImage
B
71
S
22
G
247
Posts: 3,756
Reputation: 137,558

Post » Sat Jun 27, 2015 1:08 am

That's right, triggers don't follow the execution order like regular events. They act like traditional programming events that are only executed at the exact moment they happen. But that has no relation to the OR block, it should work normally like the manual transcription you quoted.

I did a test and strangely that particularly combination of events are acting like an AND instead of an OR. It does seem like a bizarre bug, here's a capx:

C2 OR bug

- Try to click outside the square, the flash doesn't trigger.
- Try to hover the mouse on the square, the flash doesn't trigger.
- But if you hover and click the square the flash triggers.
- Next enable the other blocks and disable the previous to see how they behave differently.
Scirra Employee
B
155
S
53
G
17
Posts: 710
Reputation: 17,875

Post » Wed Jul 01, 2015 5:56 am

That seems like different behavior than I was seeing. For me it was executing on only the first item in the block as if the second wasn't there. Bizarre.
B
8
S
2
G
1
Posts: 37
Reputation: 1,476


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 5 guests