Quick Reply
Search this Thread
Test Subject
Original Poster
#1 Old 6th Jan 2026 at 4:37 PM
Default Cannot click on non-electronic objects after adding custom interaction to electronic objects
Hi I'm currently making a custom repair interaction for electronic objects (existing ones like TVs and computers, not custom or cloned objects). I'm using the unprotected DLLs. However, I'm encountering an issue. My Sims are not able to click on any objects except if they are electronic. So for example, all the existing interactions plus my custom interaction show up (and work as intended) when clicking on TVs, computers etc. But clicking on every other object doesn't even show the pie menu at all.

According to NRAAS ErrorTrap, there is an issue in the Test method, which makes sense since the Run method works, but the pie menus somehow get messed up. Also the error message shows "System.NullReferenceException: A null value was found where an object instance was required.", but since I'm checking whether the object is null or not in the method, I'm not sure what it could mean here. If necessary I can provide the whole script error description by ErrorTrap.

Here is the code snippet:

Code:
private sealed class Definition : InteractionDefinition<Sim, IGameObject, RepairObject>
            {
                public override string GetInteractionName(Sim a, IGameObject target, InteractionObjectPair interaction)
                {
                    return "Repair object";
                }
                public override bool Test(Sim actor, IGameObject target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
                {
                    if (actor.SimDescription.TeenOrAbove)
                    {
                        if (actor.IsSleeping || target.InUse || target == null)
                        {
                            return false;
                        }
                        if (!target.Repairable.Broken || (target.Repairable.ObjectRepairableType != RepairableComponent.RepairableType.Electrical))
                        {
                            return false;
                        }
                        return true;
                    }
                    return false;
                }
            }


I tried GameObject instead of IGameObject, but it didn't work either. I also tried to change the access modifiers (like changing public to private or protected), but I got an error notification, saying that the modifiers can't be changed.

Any help or ideas how to fix this are appreciated
Test Subject
#2 Old 6th Jan 2026 at 10:33 PM
Quote: Originally posted by amypilz
Any... ideas


I'm terribly out of touch, but since your code works but original don't and you use overrides - my guess there some lines in originals you "override"
Imagine Wonderfully!
staff: trainee moderator
#3 Old 6th Jan 2026 at 11:34 PM
I think the issue is that you're trying to reference RepairableComponent which not all objects have, so it only ends up working on electronic items because of the electrical type check + the existing repairable component. So you'd need to add a check if the target does have one. Also you don't need to check if the target itself is null, because as long as you can click on it then it exists

- When one gets inspired by the other, the one inspires another - Anything is Possible.

You can view some of my WIPs and other stuff for TS3 on my Twitter here ---> https://twitter.com/SweetSavanita
Test Subject
Original Poster
#4 Old 7th Jan 2026 at 3:38 AM
Quote: Originally posted by TheSweetSimmer
I think the issue is that you're trying to reference RepairableComponent which not all objects have, so it only ends up working on electronic items because of the electrical type check + the existing repairable component. So you'd need to add a check if the target does have one. Also you don't need to check if the target itself is null, because as long as you can click on it then it exists


That was exactly the issue, thank you so much! Since it adds the interaction to all game objects, those who don't have a repairable component threw an error since it referenced a non existing one. Instead of checking if the target is null, I'm now checking if the repairable component is null, and if it doesn't exist, the interaction won't get added. Thanks again!
Back to top