Pick instances from dicitonary and then compare

0 favourites
  • 5 posts
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • 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?


  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

  • 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!


  • 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.

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

    Thanks a billion !

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)