Pick instances from dicitonary and then compare

Get help using Construct 2

Post » Sun Jun 11, 2017 4:00 pm

Hey guys

I really need to do this and I can't seem to pull it off.
I have a dictionary object which has keys with the values that are essentially UIDs of other objects. I need to pick all the objects which have their UIDs as values in the dictionary and then I need to pick highest of some var between the picked instances from the object... In short I need to pick objects with the help of a dictionary and then compare the picked objects between themselves...can I do this?

Cheers!
B
18
S
3
Posts: 65
Reputation: 994

Post » Sun Jun 11, 2017 4:39 pm

If they are instances of the same object, give them a instance Boolean 'Picked'.
If they are different objects, add them all to a family, and assign the Boolean 'Picked' to the family.

Some condition that captures when this can happen. <-- no idea, you did not explain this part.
___Empty condition.
________Set 'Picked' to false <-- set them all to the starting point
___For each dictionary key
___Pick object with UID = int(Dictionary.CurrentKey) (or CurrentValue, depends on how you filled it)
________Set 'Picked' to TRUE for the picked object
___Is boolean instance variable set (for object) < picks those we marked in previous loop
___Pick highest/lowest (instance var for object)
________At this point the object is picked and you can trow actions at it
Last edited by 99Instances2Go on Sun Jun 11, 2017 5:14 pm, edited 2 times in total.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Jun 11, 2017 4:45 pm

Hey, this looks great! Thanks! I have to ask though...will this work if there are multiple separate dictionaries all doing the same thing? Some of the objects's UIDs can be in several dictionaries...will this work none the less?

Thanks again!

Cheers!
B
18
S
3
Posts: 65
Reputation: 994

Post » Sun Jun 11, 2017 5:13 pm

Bring the separate dictionary's in a family.

Now you can run trough them with For Each (family).

I always have problems with picking dictionary instances, i gave up on that.

Why not use 1 array ?
Store At(x,y)
x = 0 is first dictionary ... x=1 is second ... and so on
y = 0 is first UID ... y=2 second UID ... and so on ...

Meaning ... the value Array.at(4,6) represents the UID in the 5th dictionary and the 7th UID.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Jun 11, 2017 5:25 pm

Yeah, that might really work. I'm gonna try it out right now!

Thanks a billion :)!
B
18
S
3
Posts: 65
Reputation: 994


Return to How do I....?

Who is online

Users browsing this forum: maddy467, work3 and 8 guests