PDA

View Full Version : Getting Sim object in a relationship loop?


Diriel
3rd Jul 2011, 12:45 AM
Yo. So I have need to access all of the active sims' relationships. This isn't too hard at all, the main issue is getting any information other than the float value that specifies how much the sims likes you.

Sim sim = Sim.ActiveActor;
List<IMiniRelationship> miniRelationships = Relationship.GetMiniRelationships(sim.SimDescription);
foreach (IMiniRelationship current in miniRelationships)
{
sim.ShowTNSIfSelectable(" - " + current.CurrentLTRLiking.ToString(), StyledNotification.NotificationStyle.kSystemMessage);
}

As you can see, this code creates a notification for each relationship showing you the float value.

The issue is that I can't seem to get a reference to the sim that the relationship is with, and so can't get that sims' name, or any other information.
Note that this is simply a test and not my end goal, so I don't simply need the sims' name, I need I reference to the sim itself, although the name would be a start. xD

If anyone has any clue here I'm going wrong, any info would be appreciated. Also if anyone knows of any mods that manage to do a similar thing, that would help as I could take a quick sneaky peak at how it's done.

Thanks in advance.

Diriel


--Update

As ever when I post on a forum, I've figured it out shortly after. Very annoying habit of mine.

For anyone needing to do something similar this is how it's done;
Sim sim = Sim.ActiveActor;
foreach (Relationship current in sim.SocialComponent.Relationships)
{
Sim createdSim = current.SimDescriptionB.CreatedSim;
if (createdSim != null)
{
sim.ShowTNSIfSelectable(createdSim.FirstName+" "+createdSim.LastName+" - " + current.CurrentLTRLiking.ToString(), StyledNotification.NotificationStyle.kSystemMessage);
}
}