Pick from Family by Name

This forum is currently in read-only mode.
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.
  • I have a family of objects and I need to pair up some other instances of another object to work with them. Let's say I have 10 objects with names like ob1, ob2, ob3, etc and they're all in the Family named "family." I want to match up a separate instances of another kind of object called Box, so for each instance of Box I give a PV with the name of its corresponding object from the objects in the family I'm using.

    Basically, they're being linked with Box storing a PV of the Ob#'s name. However, I cannot find any way to pick the right Ob# by name. I want to do something like this:

    "If Box.value('label') = family.name > Do X"

    Note: It MUST be able to pick the instance of which family member who's name it was looking for when if plays the action. I really don't want to have to make a PV for each Ob# just to store the object's own name as that seems silly and shouldn't be necessary. I'm doing this so I don't have to manually make an event for each Box and Ob# to get them to do what I want. I just want it in one generic event working for them all.

    I've thought of making each Ob# an instance of a single object, and I'd then use a PV for picking them in each case anyway, but I think I'd rather hold off on that as I'd rather keep these separate objects for now (they're text objects by the way).

    Edit: This would essentially be "Get Name" from a Family of objects so I could choose the right object based on it's name. This means it would run through all the names and of objects in the Family and see if they matched the PV they're being compared against (within a "Compare PV"). Once again, the point is to do a generic (or dynamic) event that can be used for each case where an object needs picked from a Family by name.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here's a fairly simple way to do it using a hash table. The hash is used to map the obj names and the object type's OID. The OID or object ID is different for each type of object. Different instances of the same object type will have the same ID.

    Example: Pickbyname.cap

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