Severely depressed from UID pick failure

Get help using Construct 2

Post » Wed Jan 25, 2012 3:47 am

I'm so frustrated I feel like punching a baby.

Can anyone please tell me what the heck is going on with this code? A pick operation is not picking *anything* even though the UID is valid and the object type is correct.

I'm seriously about to cry, I've been at this for the last two hours.

Here's the capx for anyone who could shed some light on this...
(It's pretty simple)

Pick failure project

I gutted the project file so that it would be a small capx download, cause this originally comes from a much larger project.

Help me obi-wan kenobi, you're my only hope (bends over really ackwardly)
-- cacotigon
B
30
S
6
G
8
Posts: 232
Reputation: 6,119

Post » Wed Jan 25, 2012 4:04 am

I'm not sure what I did, and even if this is a solution to the problem, but on line 2, change
Set UID_CommonArray to BaseArray.UID

to

Set UID_CommonArray to BaseArray.UID + 1
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Wed Jan 25, 2012 4:18 am

Why not use the pick by furthest/nearest? Just use the exact x-y co-ords for the object (as long as it's stationary, or use [object-name]-x/y), and it'll never fail.
Zelda Gamekit (my project)

Example capxs I have made:
Zelda-Style Inventory
Zelda Hearts System

The unwritten "How do I" capx etiquette! Nearly always provide a capx of the problem you have, and try to isolate the problem and/or no capx above 10 MB. :)
B
38
S
19
G
26
Posts: 438
Reputation: 16,581

Post » Wed Jan 25, 2012 6:49 am

Just a few remarks.
I don't get why you create two instances of the array object.
Disabling both actions of creation of an instance in "GameInitialization" seems to make things work as expected.

The array object is "global" to the project, you can access/size/use it at will from any event sheet.

Another thing to have an eye on is the function plugin. It may act on the SOL (and so on the picking).
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Wed Jan 25, 2012 8:56 am

I think you just need to let c2 create the array before trying to pick it.
It seems c2 need a tick to do that.
This seems to work as expected :
arrayPicking.capx
Last edited by Yann on Sun Sep 14, 2014 11:54 am, edited 2 times in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Wed Jan 25, 2012 2:41 pm

Kyatric, as I mentioned before, this code is from a much larger project, one where I initialize several different arrays, each containing different information. Sorry, can you explain what SOL means? Thanks for the info about the function plugin, I will try removing it and seeing if the same problem occurs.

Yann, that seems strange, especially since I can access the arrays class properties immediately after create object including the UID, which would seem to indicate that the object has been already created. Unfortunately, if I make this change, my code order is going to get messed up, I guess I might have to make a IsReady var and group everything else under.

I'm still kind of unhappy about this, in normal Construct behavior, after you create an object, any further commands will act on that object essentially an automatic pick operation occurs, so why doesn't a deliberate pick work? So frustrating.
B
30
S
6
G
8
Posts: 232
Reputation: 6,119

Post » Wed Jan 25, 2012 4:05 pm

SOL is the Selected Object List.
Basicly the list that contains the instances you picked (by filtering with conditions) and to which the actions will be applied.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Wed Jan 25, 2012 5:01 pm

This doesn't work because subevents carry on picking where the parent left off.

The event runs like this:
1. First array instance created. The 'create' action picks it.
2. Its UID is saved.
3. Second array instance created. The 'create' action picks it. This is now the only picked array! The other array instance is no longer picked!
4. Enter the subevent. The subevent inherits the parent event's picked objects, i.e. *only* the second created instance.
5. Conditions only ever run on the picked instances. So "pick by UID..." in that subevent will only pick from the second created instance, which does not have the UID you want, so the event can never run!

There's no bug here, it's just Construct 2 working normally.

There are three possible solutions:
1) Use system 'Pick all BaseArray' before the 'Pick by UID' to go back to both arrays picked rather than just the second array picked.
2) Make a new start of layout event and move the pick by UID to there.
3) Don't use multiple instances of array - it's much better to use two different array object types than two instances of the same array (i.e., insert a new array in to the layout again and use that).
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Wed Jan 25, 2012 5:03 pm

that seems strange, especially since I can access the arrays class properties immediately after create object including the UID, which would seem to indicate that the object has been already created.
You can access all Action/Condition/Expression of any object type of your project any time. The fact that an instance is created at runtime or not is irrelevant, as there's no parsing of the event sheet to check if you created something before accessing it.

Anyway, I gave it another try as it is indeed a weird behavior.
It seems that somehow, creating another array before trying to pick the first one makes the picking fail.
So that seems to work like that.
arrayPicking2.capx

I wonder if it deserves a bug report or not.
@Ashley should be the judge.
Last edited by Yann on Sun Sep 14, 2014 11:55 am, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Wed Jan 25, 2012 5:08 pm

@Ashley
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU!

That's exactly what is happening! I had no idea that a PICK command in a subevent could only pick from its inherited "pick list" which happens on a Create object command. Subeventing the Pick UID code under a Pick All completely fixes the problem. I think I've got a much better understanding of the code-flow now. Also, I created a completely new project and tested extensively with sprites/arrays/etc and there doesn't seem to be any bugs. Hurray!cacotigon2012-01-25 17:09:44
B
30
S
6
G
8
Posts: 232
Reputation: 6,119

Next

Return to How do I....?

Who is online

Users browsing this forum: Timedoor Indones and 23 guests