- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Trouble adding interactions to cell/smart phones
- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Trouble adding interactions to cell/smart phones
Replies: 2 (Who?), Viewed: 165 times.
#1
7th Apr 2024 at 12:08 AM
Posts: 299
Thanks: 1063 in 2 Posts
Trouble adding interactions to cell/smart phones
After a long break in modding I've decided to get back at it, and have been adding some things to my Apartments & Roommates Fix mod. I managed to add a new option to the Roommate Services... menu, but the new option only appears on home phones bought from Buy mode. Just the usual 3 options show up on smart/cell phones. I've tried everything I can think of including specifically adding things like this in OnPreLoad()
Code:
PhoneCell[] cell = Sims3.Gameplay.Queries.GetObjects<PhoneCell>(); for (int j = 0; j < cell.Length; j++) { PhoneCell cell2 = cell[j]; RoommatesFix.AddInteractionsCell(cell2); } PhoneSmart[] smart = Sims3.Gameplay.Queries.GetObjects<PhoneSmart>(); for (int k = 0; k < smart.Length; k++) { PhoneSmart cell3 = smart[k]; RoommatesFix.AddInteractionsSmart(cell3); }
AddInteractions is a custom interaction that adds the interactions to the home phones, but won't work on the smart phones. Anyone have any ideas? Thanks!
Advertisement
#2
8th Apr 2024 at 12:15 AM
Posts: 538
Thanks: 5468 in 26 Posts
Quote: Originally posted by pjsutton
After a long break in modding I've decided to get back at it, and have been adding some things to my Apartments & Roommates Fix mod. I managed to add a new option to the Roommate Services... menu, but the new option only appears on home phones bought from Buy mode. Just the usual 3 options show up on smart/cell phones. I've tried everything I can think of including specifically adding things like this in OnPreLoad()
Code:
PhoneCell[] cell = Sims3.Gameplay.Queries.GetObjects<PhoneCell>(); for (int j = 0; j < cell.Length; j++) { PhoneCell cell2 = cell[j]; RoommatesFix.AddInteractionsCell(cell2); } PhoneSmart[] smart = Sims3.Gameplay.Queries.GetObjects<PhoneSmart>(); for (int k = 0; k < smart.Length; k++) { PhoneSmart cell3 = smart[k]; RoommatesFix.AddInteractionsSmart(cell3); } AddInteractions is a custom interaction that adds the interactions to the home phones, but won't work on the smart phones. Anyone have any ideas? Thanks! |
This is how I added new smart phone interactions in my Investment Mod:
Code:
private static void OnWorldLoadFinished(object sender, EventArgs e) { if (Household.ActiveHousehold != null) { InitInjection(); } else { EventTracker.AddListener(EventTypeId.kEventSimSelected, OnSimSelected); } } private static ListenerAction OnSimSelected(Event e) { if (Household.ActiveHousehold != null) { InitInjection(); return ListenerAction.Remove; } return ListenerAction.Keep; } private static void InitInjection() { PhoneSmart[] objects2 = Sims3.Gameplay.Queries.GetObjects<PhoneSmart>(); foreach (PhoneSmart phoneSmart in objects2) { AddPhoneInteractions(phoneSmart); } EventTracker.AddListener(EventTypeId.kInventoryObjectAdded, OnObjectChanged); EventTracker.AddListener(EventTypeId.kObjectStateChanged, OnObjectChanged); } private static ListenerAction OnObjectChanged(Event e) { PhoneSmart phoneSmart = e.TargetObject as PhoneSmart; if (phoneSmart != null) { AddPhoneInteractions(phoneSmart); } return ListenerAction.Keep; } private static void AddPhoneInteractions(PhoneSmart phoneSmart) { foreach (InteractionObjectPair pair in phoneSmart.Interactions) { if (pair.InteractionDefinition.GetType() == MobileInvestment.ResearchStocks.Singleton.GetType()) { return; } } phoneSmart.AddInventoryInteraction(MobileInvestment.ResearchStocks.Singleton); phoneSmart.AddInventoryInteraction(MobileInvestment.InvestOneThousand.Singleton); phoneSmart.AddInventoryInteraction(MobileInvestment.InvestTwoThousand.Singleton); phoneSmart.AddInventoryInteraction(MobileInvestment.InvestFiveThousand.Singleton); phoneSmart.AddInventoryInteraction(MobileInvestment.InvestTenThousand.Singleton); phoneSmart.AddInteraction(MobileInvestment.ResearchStocks.Singleton); phoneSmart.AddInteraction(MobileInvestment.InvestOneThousand.Singleton); phoneSmart.AddInteraction(MobileInvestment.InvestTwoThousand.Singleton); phoneSmart.AddInteraction(MobileInvestment.InvestFiveThousand.Singleton); phoneSmart.AddInteraction(MobileInvestment.InvestTenThousand.Singleton); }
#3
8th Apr 2024 at 3:49 AM
Posts: 299
Thanks: 1063 in 2 Posts
Quote: Originally posted by Twinsimming
This is how I added new smart phone interactions in my Investment Mod:
Code:
private static void OnWorldLoadFinished(object sender, EventArgs e) { if (Household.ActiveHousehold != null) { InitInjection(); } else { EventTracker.AddListener(EventTypeId.kEventSimSelected, OnSimSelected); } } private static ListenerAction OnSimSelected(Event e) { if (Household.ActiveHousehold != null) { InitInjection(); return ListenerAction.Remove; } return ListenerAction.Keep; } private static void InitInjection() { PhoneSmart[] objects2 = Sims3.Gameplay.Queries.GetObjects<PhoneSmart>(); foreach (PhoneSmart phoneSmart in objects2) { AddPhoneInteractions(phoneSmart); } EventTracker.AddListener(EventTypeId.kInventoryObjectAdded, OnObjectChanged); EventTracker.AddListener(EventTypeId.kObjectStateChanged, OnObjectChanged); } private static ListenerAction OnObjectChanged(Event e) { PhoneSmart phoneSmart = e.TargetObject as PhoneSmart; if (phoneSmart != null) { AddPhoneInteractions(phoneSmart); } return ListenerAction.Keep; } private static void AddPhoneInteractions(PhoneSmart phoneSmart) { foreach (InteractionObjectPair pair in phoneSmart.Interactions) { if (pair.InteractionDefinition.GetType() == MobileInvestment.ResearchStocks.Singleton.GetType()) { return; } } phoneSmart.AddInventoryInteraction(MobileInvestment.ResearchStocks.Singleton); phoneSmart.AddInventoryInteraction(MobileInvestment.InvestOneThousand.Singleton); phoneSmart.AddInventoryInteraction(MobileInvestment.InvestTwoThousand.Singleton); phoneSmart.AddInventoryInteraction(MobileInvestment.InvestFiveThousand.Singleton); phoneSmart.AddInventoryInteraction(MobileInvestment.InvestTenThousand.Singleton); phoneSmart.AddInteraction(MobileInvestment.ResearchStocks.Singleton); phoneSmart.AddInteraction(MobileInvestment.InvestOneThousand.Singleton); phoneSmart.AddInteraction(MobileInvestment.InvestTwoThousand.Singleton); phoneSmart.AddInteraction(MobileInvestment.InvestFiveThousand.Singleton); phoneSmart.AddInteraction(MobileInvestment.InvestTenThousand.Singleton); } |
Thanks for this! It worked! Except now the interactions (which were the same ones) on the Home phones was borking things up! Oy vey! So, I removed those for now.
Who Posted
|