- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Errors scripting Custom Interactions
- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Errors scripting Custom Interactions
Replies: 3 (Who?), Viewed: 568 times.
#1
17th Aug 2021 at 5:52 PM
Posts: 732
Thanks: 288 in 5 Posts
Errors scripting Custom Interactions
I've created a hidden skill and am adding skill-based interactions to it. Before I gate them based on skill level, I want to just add and test them in the game first but keep running into the problem where the game hangs on world loading and this error: <ExceptionData>simulating object is null unable to obtain an interaction object A null value was found where an object instance was required. #0: 0x00043 callvirt in Sims3.Gameplay.Olomaya.Sims3.Gameplay.Olomaya.ReligionSocials:AddInteractionsSims (Sims3.Gameplay.Actors.Sim) ([28BB6800] ) #1: 0x00016 call in Sims3.Gameplay.Olomaya.Sims3.Gameplay.Olomaya.ReligionSocials:OnWorldLoadFinished (object,System.EventArgs) ([27A988A0] [281DECA8] ) #2: 0x00000 in System.System.EventHandler:Invoke (object,System.EventArgs) (29649050 [27A988A0] [281DECA8] ) #3: 0x00013 callvirt in Sims3.SimIFace.Sims3.SimIFace.World:OnWorldLoadFinished () () </ExceptionData>
This is what I have in the script for the two issue areas highlighted above:
Code:
private static void OnWorldLoadFinished(object sender, EventArgs e) { foreach (Sim sim in Sims3.Gameplay.Queries.GetObjects<Sim>()) { if (sim != null) { AddInteractionsSims(sim); } { EventTracker.AddListener(EventTypeId.kSimInstantiated, new ProcessEventDelegate(ReligionSocials.OnSimInstantiated)); } } } private static void AddInteractionsSims(Sim sim) { if (!sim.SimDescription.ChildOrAbove) { return; } foreach (InteractionObjectPair interaction in sim.Interactions) { if (interaction.InteractionDefinition.GetType() == Pray.Singleton.GetType() || interaction.InteractionDefinition.GetType() == AskAboutReligion.Singleton.GetType() || interaction.InteractionDefinition.GetType() == PraiseTheWatcher.Singleton.GetType() || interaction.InteractionDefinition.GetType() == DeclareAHeathen.Singleton.GetType()) { return; } } sim.AddInteraction(Pray.Singleton); sim.AddInteraction(AskAboutReligion.Singleton); sim.AddInteraction(PraiseTheWatcher.Singleton); sim.AddInteraction(DeclareAHeathen.Singleton); }
Advertisement
#2
5th Sep 2021 at 8:15 PM
Last edited by zoe22 : 7th Sep 2021 at 3:52 PM.
Posts: 562
Thanks: 3598 in 11 Posts
Hey @olomaya I know it's been a little while, so maybe hopefully you've already fixed the issue!
If not though, I'm not totally sure what the issue is. This section of code looks alright to me, and if it compiled fine, that does make it a bit less obvious what the problem is, but it might be worth either seeing the rest of your code ie the interactions, or uploading the package/solution here for someone to have a closer look.
A couple things though, that I don't think would cause the error, but may cause issues/can just be cleaned up:
Line 10 (adding the event listener), is currently in the for loop, so will happen for every sim in the world. This isn't necessary and it can just be done once, in the OnWorldLoadFinished method, so you could put that line before looping through all the sims in the world.
In the loop lines 21-27, if any one of those interactions are there, none of them will be added. This might work fine, but I don't know if there could be a case where some of the interactions aren't attached to the sim, but some are, and in that case you probably want to add the ones that aren't. So you would then need to do it either by looping through the interactions multiple times, each time checking for one of your custom ones and adding it if not there, or maybe by removing your interactions and then adding them back on might work.
Anyway, hopefully someone can actually help with the error you're getting :p
If not though, I'm not totally sure what the issue is. This section of code looks alright to me, and if it compiled fine, that does make it a bit less obvious what the problem is, but it might be worth either seeing the rest of your code ie the interactions, or uploading the package/solution here for someone to have a closer look.
A couple things though, that I don't think would cause the error, but may cause issues/can just be cleaned up:
Line 10 (adding the event listener), is currently in the for loop, so will happen for every sim in the world. This isn't necessary and it can just be done once, in the OnWorldLoadFinished method, so you could put that line before looping through all the sims in the world.
In the loop lines 21-27, if any one of those interactions are there, none of them will be added. This might work fine, but I don't know if there could be a case where some of the interactions aren't attached to the sim, but some are, and in that case you probably want to add the ones that aren't. So you would then need to do it either by looping through the interactions multiple times, each time checking for one of your custom ones and adding it if not there, or maybe by removing your interactions and then adding them back on might work.
Anyway, hopefully someone can actually help with the error you're getting :p
#3
30th Sep 2021 at 10:37 AM
Posts: 732
Thanks: 288 in 5 Posts
Quote: Originally posted by zoe22
Hey @olomaya I know it's been a little while, so maybe hopefully you've already fixed the issue! If not though, I'm not totally sure what the issue is. This section of code looks alright to me, and if it compiled fine, that does make it a bit less obvious what the problem is, but it might be worth either seeing the rest of your code ie the interactions, or uploading the package/solution here for someone to have a closer look. A couple things though, that I don't think would cause the error, but may cause issues/can just be cleaned up: Line 10 (adding the event listener), is currently in the for loop, so will happen for every sim in the world. This isn't necessary and it can just be done once, in the OnWorldLoadFinished method, so you could put that line before looping through all the sims in the world. In the loop lines 21-27, if any one of those interactions are there, none of them will be added. This might work fine, but I don't know if there could be a case where some of the interactions aren't attached to the sim, but some are, and in that case you probably want to add the ones that aren't. So you would then need to do it either by looping through the interactions multiple times, each time checking for one of your custom ones and adding it if not there, or maybe by removing your interactions and then adding them back on might work. Anyway, hopefully someone can actually help with the error you're getting :p |
Thanks so much, @zoe22! I dropped this off before going on a long holiday so I'm just getting back to it now. Here's the full solution if that helps anything. Thanks again!
Attached files:
OlomayaReligionSkill.zip (587 Bytes, 4 downloads) |
Who Posted
|