OR-block ignores instances picked in parent event

Report Construct 2 bugs here.

Post » Thu Mar 08, 2018 7:29 am

I hit this bug again today and it took me almost 2 hours to figure it out!

This time it was a bit different. I have two sprites in a container, and an event like this:

Code: Select all
Sprite1 DragDrop is dragging

   Sprite2 var=foo    -> Sprite2 set x to 100
   or
   Sprite2 var=bar

   Else        -> Sprite2 set x to 200


The Or-block and its Else part are supposed to test only one instance of Sprite2 (the one in the container with Sprite1 which is being dragged).
But instead, these subevents sometimes pick some other instances on the layout...
Changing the Or-block to "System compare two values: Sprite2.var=x | Sprite2.var=y" resolved the problem.


@Ashley , will this ever be fixed?
B
17
S
9
G
156
Posts: 2,203
Reputation: 82,987

Post » Mon Mar 26, 2018 11:32 am

@dop2000
Just saw this and found interesting because I have similar events in my game

but I have never assumed that only the associated container sprites are picked (so I filter with a uid check as well, or similar)
Is it normally expected that associated container sprites are automatically selected?
NOTE: There is a high a probability that I am wrong.
B
52
S
27
G
7
Posts: 460
Reputation: 8,962

Post » Mon Mar 26, 2018 12:02 pm

@NetOne
Yes, this is one of the main features of containers - when you pick one object, other objects from the container are picked automatically.
B
17
S
9
G
156
Posts: 2,203
Reputation: 82,987

Post » Mon Mar 26, 2018 12:35 pm

@dop2000

Oh.. Damn, so I totally missed this!
(And Ive just seen it is right there in the manual , really should read that from time to time)
Cheers.

This would make life a lot easier..... it means I could kill of a ton of events that are probably eating a lot of CPU.
But it looks like it is not dependable unless the OR block is taken out of the equation :(

Still I have something to look into tonight.... Thanks....
NOTE: There is a high a probability that I am wrong.
B
52
S
27
G
7
Posts: 460
Reputation: 8,962

Post » Sat Mar 31, 2018 9:17 am

I gonna crazy down. Please somebody help me resolve this small *peaceOS

Image
https://www.dropbox.com/s/oj96gj0vng3zf6g/Screenshot_BUG.png



I asking my self - HOW IT WORK? :D
p.s. OMG ...and how insert image to post? :D
B
7
S
2
G
1
Posts: 23
Reputation: 1,106

Post » Sat Mar 31, 2018 9:31 am

B
7
S
2
G
1
Posts: 23
Reputation: 1,106

Post » Mon Apr 16, 2018 7:07 am

@Ashley
@dop2000
Woooow... I spent hours trying to understand what I was doing wrong there. I made a small .CAPX too and was about to post the bug when I saw your post with the flaming icon, and I was shocked to read a title I was about to write.

So yes, it's a very annoying bug and I have made a small example too: https://www88.zippyshare.com/v/5KTgQmw3/file.html

Basically, you have two identical characters, two zones and a blue square.

If selected character is moving over Zone 1 or 2, hide Blue square
If selected character is NOT moving over Zone 1 or 2, then show Blue square.
(Move them with basic keyboard arrows)

And here the bug is that, even if the selected character moves, while the second character is over a zone, the blue square is still displayed while it should be hidden.
I know it's not something you can understand right away in 5 seconds, but after playing with it for a few minutes you understand that it's not reacting the way it's supposed to.
I know you guys are working on C3 and the progress you've made so far is amazing, but I didn't think such a core mechanism wouldn't act as intended.

[EDIT] : Indeed, the "simplest" workaround right now is to avoid using "OR" blocks combined with "Pick ...". The annoying thing is that it makes you multiply events unnecessarily...
B
18
S
4
G
3
Posts: 96
Reputation: 2,964

Post » Mon Apr 16, 2018 3:49 pm

dop2000 wrote:(...)
Code: Select all
Sprite1 DragDrop is dragging

   Sprite2 var=foo    -> Sprite2 set x to 100
   or
   Sprite2 var=bar

   Else        -> Sprite2 set x to 200

(...)


The way the code is put, i think the problem lies on Construct messing with the OR and Else, last being used against "Sprite2 var=bar" only.


@Telyko by looking quickly couldn't it be a logic problem?
I'm at work so can't see your example.
B
18
S
7
G
4
Posts: 154
Reputation: 4,113

Post » Tue Apr 17, 2018 10:53 am

@Cassianno

I really tried to make an example as simple as possible to understand but I'm not sure I succeeded:

Here's how it breaks down

If click on Character then Pick only this Character

Character (UID = 1) and Character (UID = 2) (Same object)
One Character is on top of Zone A, and second Character is on top of Zone B

EVENT:

Code: Select all
Pick selected Character only (After click on Character)              < C2 IGNORES THIS
   
   If Character is over Zone A
   OR
   if Character is over Zone B
   
      If Character is 8-Directions Moving
      OR
      If Character is Pathfinding Moving on Path
         
         Hide Blue Square

      If Character is NOT 8-Directions Moving
      OR
      If Character is NOT Pathfinding Moving on Path

         Show Blue Square


So the fact that there are OR blocks in the middle of the event in sub-events, C2 ignores the "Pick only this instance of the object" instead it picks all objects so the behavior doesn't work as intended. The blue square should react only to the selected Character where here it's also affected by the 2nd one who's not selected. You pick a character, you move it over a zone, this should hide the blue square and show it only when character stops moving over the zone. But blue square is still displayed because the 2nd character which SHOULDN'T be picked is over a zone and not moving.
B
18
S
4
G
3
Posts: 96
Reputation: 2,964

Post » Tue Apr 17, 2018 12:17 pm

Maybe this thread refers to the same error.
I'm not sure.

bug-with-key_t202146
B
35
S
14
G
22
Posts: 916
Reputation: 15,100

PreviousNext

Return to Bugs

Who is online

Users browsing this forum: No registered users and 0 guests