How to compare an objects name with a string?

I’ve been working on a automatic family tree system and so far it has been working well, but its more of a list so far and I’ve been trying to figure out how to filter out the NPCs that don’t have the same last name which has proven difficult.

The previous image is what I have working so far and as you can see the list is filled with everyone rather than just their families. Below is how the NPCs are added to the list, I need to find a way to compare every NPCs last name and make it so only the family members are added to their corresponding lists.

Any help is appreciated as I’ve spent a couple of days racking my brain around the issue.

Your function needs an input which indicates which family to list/get. I’d recommend using an int, otherwise you’re in for a world of pain when it gets to Smith :wink:

Hi, thanks for the response, I’ve been working on implementing what you said and I’ve got the family IDs working, however when I try to compare the IDs with each other it at the branch in the Image it always comes back false, while using a print string i found out the ID the branch is getting is always 0.

Here is a few other screen grabs from how I set up the IDs:

The final image was the ID being set into the individual NPCs profile, any idea on why the ID check at the end doesn’t match up to the set IDs when they are spawned?

Yes, I don’t think you’re setting it. After that big switch statement, you need to put the ID into a ‘make profile’ and write that into the structure with the rest of the info.

What I’m saying is, the ID should be in all the structures ( profiles ) where the surname is. Because it’s basically the unique surname. So, whenever you’re writing a new person into the tree, you have all their details which you put into the profile structure, but then you also need to write the ID in there.

If it’s a new ID, you just use the next integer.

( the ID isn’t a ‘code concept’ it’s actually part of the family data )

you only want to have a list where you can find all the family names which their family members, right? Why not use a simple map for that, like this:

you can then use the map->getKeys to iterate with a loop over all family names, and get the objectReferences from each family string which gives you the family members.
in my screenshot the makeLiteralString is where your familyName from the struct will go.

Hi - me again :slight_smile:

Just took another look at your code.

Two things you need to do:

  1. The ID is just the ‘next’ integer. So you don’t need that big swtich. When you come to allocate an ID, you just use to next integer higher than your current highest ID.

  2. You ‘database’ is a collection of BPs ( right? ). The ID just lives in the BP along with everything else ( name, date of birth, yada yada ).

When you want to know everyone in one family, you just loop through all the objects looking for ones with the correct ID.

Tell me if this is of any use…

Hi, I don’t quite understand what you mean, how can families know what ID they are without it being set? So I’m pretty sure it would need to be set which is what the switch is for. and with the loop wouldn’t I have to compare the last names rather than the IDs? because I want the list to only show the NPCs with the same last name. Correct me if I’m wrong.

You must have a crucial point in your code where you know the person you’re creating is from a new family. At that point the next integer gets allocated to the family as their ID. Everyone in that family gets that ID ( actually stored with the variables in the BP ).

When you want to find everyone from one family, you just loop through the BPs looking for that ID.

When you ‘playing the game’ and want to specify a specific family, you can’t use a name, because that’s no unique. You could say 'I want everyone in this person’s family. In which case, because you have a particluar person, you can lookup their ID and find everyone in their family.

If it’s still not clear, I will send you a little project.

Hi, thanks for the information I’ve been working on it a little bit and need to change around some nodes but it semi works so far. Thanks! All I need to do now is figure out how to remove themselves from the list and make it more dependable as it doesn’t work all the time, I might be using it wrong its hard to tell with something I’ve never used.