PDA

View Full Version : [Solved] Nested IF from hell...


MDM
30th May 2012, 09:54 PM
I'm usually good at these, but this one in particular had me screaming in pain cos I can't figure out how to accomplish what I want :cry:

This is what I have so far :

protected override bool Test(Sim a, Stereo target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
{
if (target.Repairable.Broken || isAutonomous && a.Motives.GetValue(CommodityKind.Fun) > (float)Tuning.kMotiveThresholdToAllowConverse && a.Motives.GetValue(CommodityKind.Social) > (float)Tuning.kMotiveThresholdToAllowConverse)
{
return false;
}
if (target.InUse && a.HasTrait(TraitNames.Insane))
{
greyedOutTooltipCallback = new GreyedOutTooltipCallback(Common.greyedOutTooltipCallbackObjectInUse);
return false;
}
return a.HasTrait(TraitNames.Insane) && a.SimDescription.TeenOrAbove;
}

What I want to accomplish is, keeping everything as it is, just adding that the sim actually using the interaction with the object, will have the string available, so Test should return true.
I tried adding a == null but it makes the string available for all, even if in use.

Can anyone help me here, please?

Consort
30th May 2012, 10:25 PM
Not 100% sure what you're trying to do

target.IsActorUsingMe(a)

would check if a specific sim is using a specific stereo.

Purrhaps something like


protected override bool Test(Sim a, Stereo target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)

{

if (target.Repairable.Broken || isAutonomous && a.Motives.GetValue(CommodityKind.Fun) > (float)Tuning.kMotiveThresholdToAllowConverse && a.Motives.GetValue(CommodityKind.Social) > (float)Tuning.kMotiveThresholdToAllowConverse)

{

return false;

}
if (!target.IsActorUsingMe(a))
{
if (target.InUse && a.HasTrait(TraitNames.Insane))

{

greyedOutTooltipCallback = new GreyedOutTooltipCallback(Common.greyedOutTooltipCallbackObjectInUse);

return false;

}
}
return a.HasTrait(TraitNames.Insane) && a.SimDescription.TeenOrAbove;

}


Not sure what the insane trait check does, you will know better if you want that or not

MDM
30th May 2012, 10:45 PM
Not 100% sure what you're trying to do

target.IsActorUsingMe(a)

would check if a specific sim is using a specific stereo.

Purrhaps something like

//////

Not sure what the insane trait check does, you will know better if you want that or not

Yay! That did it! :beer:

The insane trait check is there because if the target was in use, sims without the insane trait would see the greyedout tooltip, which made no sense.

Now that I know what makes it work, I can nest it better and remove the insane trait check redundancy.

Thanks a lot, you saved my brain :anime: