- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Event Tracker for new game created
- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Event Tracker for new game created
Replies: 6 (Who?), Viewed: 1101 times.
#1
21st Aug 2015 at 5:34 AM
Posts: 299
Thanks: 1054 in 2 Posts
Event Tracker for new game created
I'm having a problem with a mod: it works fine, except for when I create a new game. When starting a new game from the Main Menu, none of my alarms or event trackers that are in "OnWorldLoadFinished" are started.What do I need to do to get them to start in a new game? Is there another game state that I somehow overlooked?
Advertisement
#2
21st Aug 2015 at 6:19 AM
You mean it works when you load an existing hood, but not when you start a new one? Interesting. Is it the same behavior no matter if you start the new game right after loading the game or loading an existing game, returning to the main menu and then starting a new game? Can you show your code?
If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
#3
21st Aug 2015 at 6:57 AM
Posts: 299
Thanks: 1054 in 2 Posts
Quote: Originally posted by Buzzler
You mean it works when you load an existing hood, but not when you start a new one? Interesting. Is it the same behavior no matter if you start the new game right after loading the game or loading an existing game, returning to the main menu and then starting a new game? Can you show your code? |
Yes, it is the same behavior.
I have it set up so that it displays a series of notifications if the lot is an Apartment lot. I have been doing this: Starting a new game, choosing a household, going to Edit Town, and changing a lot into an Apartment lot. Move a family into the Apartment lot, and the messages do not come up ... and the game then does not recognize any of the new interactions I've changed for my Roommates Fix mod... until I save, go back to main menu, and load the newly created game again. Here's the code: (probably just the parts you need):
Code:
static RoommatesFix() { RoommatesFix.RoommatesStatus = new List<ulong>(); RoommatesFix.kRoommateRentDay = DaysOfTheWeek.Friday; RoommatesFix.kBillsDay1 = DaysOfTheWeek.Tuesday; RoommatesFix.kBillsDay2 = DaysOfTheWeek.Friday; RoommatesFix.kRoommateValidationTimeOfDay = 9f; RoommatesFix.kRoommateCheckTimeOfDay = 7f; RoommatesFix.kRoommateRentMultiplier = 9f; RoommatesFix.kInstantiator = false; LoadSaveManager.ObjectGroupsPreLoad += new ObjectGroupsPreLoadHandler(RoommatesFix.OnPreLoad); World.OnWorldLoadFinishedEventHandler += new EventHandler(RoommatesFix.OnWorldLoadFinished); } public static void OnWorldLoadFinished(object sender, EventArgs e) { if (Household.ActiveHousehold != null && Household.ActiveHouseholdLot != null && Household.ActiveHouseholdLot.IsApartmentLot) { Household.RoommateManager.StopAlarm(); RoommatesFix.GetNumCurrentRoommates(); AlarmManager.Global.AddAlarm(0.1f, TimeUnit.Seconds, new AlarmTimerCallback(RoommatesFix.GetNumCurrentRoommates), "GetNumCurrentRoommates", AlarmType.NeverPersisted, null); AlarmManager.Global.AddAlarm(0.1f, TimeUnit.Seconds, new AlarmTimerCallback(RoommatesFix.RoommatesCheck), "RoommatesCheck", AlarmType.NeverPersisted, null); AlarmManager.Global.AddAlarm(0.1f, TimeUnit.Seconds, new AlarmTimerCallback(RoommatesFix.NewRoommateValidation2), "NewRoommateValidation2", AlarmType.NeverPersisted, null); AlarmManager.Global.AddAlarmDay(7f, DaysOfTheWeek.All, new AlarmTimerCallback(RoommatesFix.RoommatesCheck), "RoommatesCheck", AlarmType.NeverPersisted, null); AlarmManager.Global.AddAlarmDay(RoommatesFix.kRoommateValidationTimeOfDay, DaysOfTheWeek.All, new AlarmTimerCallback(RoommatesFix.NewRoommateValidation), "RoommateValidation", AlarmType.NeverPersisted, null); EventTracker.AddListener(EventTypeId.kHouseholdSelected, new ProcessEventDelegate(OnHouseholdChanged)); } AlarmManager.Global.AddAlarm(0.1f, TimeUnit.Seconds, new AlarmTimerCallback(RoommatesFix.StoryProgressionRoommatesTweaks), "StoryProgressionRoommatesTweaks", AlarmType.NeverPersisted, null); } private static void OnPreLoad() { Phone.CallToggleRoommateServices.Singleton = new RoommatesFix.FixedCallToggleRoommateServices.Definition(); Phone.CallChangeRoommateCount.Singleton = new RoommatesFix.FixedCallChangeRoommateCount.Definition(); Phone.CallChangeRoommateType.Singleton = new RoommatesFix.FixedCallChangeRoommateType.Definition(); // Phone.CallToggleRoommateServices.Singleton = new RoommatesFix.CallToggleTenantServices.Definition(); } public static ListenerAction OnHouseholdChanged(Event e) { HouseholdUpdateEvent h = e as HouseholdUpdateEvent; if (h != null) { Household newHousehold = h.Household; ulong activeLotId2 = newHousehold.LotId; string result; string NewAddress = Sims3.SimIFace.World.GetLotAddress(activeLotId2); // RoommatesFix.GetNumCurrentRoommates(); // RoommatesFix.RoommatesCheck(); if (RoommatesStatus.Contains(activeLotId2) && activeLotId2 == Household.ActiveHousehold.LotId) { // RoommatesStatus.Add(activeLotId); Household.RoommateManager.mAcceptingRoommates = true; // Household.RoommateManager.StopAcceptingRoommates(true); result = Localization.LocalizeString("Gameplay/Interactions/Roommates:Disable", new object[0]); StyledNotification.Format formatC = new StyledNotification.Format("Roommate Services are currently enabled on " + NewAddress + ". This setting has been retrieved from the last time this lot was opened and reset to its previous state. ", ObjectGuid.InvalidObjectGuid, ObjectGuid.InvalidObjectGuid, StyledNotification.NotificationStyle.kGameMessagePositive); StyledNotification.Show(formatC); int count = 0; foreach (ulong ID in RoommatesStatus) { if (ID == Household.ActiveHousehold.LotId) { count += 1; } Household.RoommateManager.SetMaxRoommateNumber(count); // } // if (RoommateStatusShown == false) // { // RoommateStatusShown = true; } RoommatesFix.NewRoommateValidation2(); RoommatesFix.GetNumCurrentRoommates(); RoommatesFix.ShowRoommateStatus(); } if (!RoommatesStatus.Contains(activeLotId2) && activeLotId2 == Household.ActiveHousehold.LotId) { RoommatesStatus.RemoveAll(item => item == activeLotId2); Household.RoommateManager.mAcceptingRoommates = false; // Household.RoommateManager.SetMaxRoommateNumber(0); Household.RoommateManager.KickExistingRoommates(); result = Localization.LocalizeString("Gameplay/Interactions/Roommates:Enable", new object[0]); StyledNotification.Format formatD = new StyledNotification.Format("Roommate Services are currently disabled on " + NewAddress + ". This setting has been retrieved from the last time this lot was opened and reset to its previous state. ", ObjectGuid.InvalidObjectGuid, ObjectGuid.InvalidObjectGuid, StyledNotification.NotificationStyle.kGameMessagePositive); StyledNotification.Show(formatD); // } // if (RoommateStatusShown == false) // { // RoommateStatusShown = true; RoommatesFix.GetNumCurrentRoommates(); RoommatesFix.ShowRoommateStatus(); } } return ListenerAction.Keep; // RoommatesFix.RoommatesCheck(); }
Instructor
#4
22nd Aug 2015 at 4:19 AM
Posts: 516
Thanks: 4225 in 14 Posts
I'm not so familiar with how your mod works (as I haven't been following your another thread here) but I just noticed this:
Is there a specific reason why you use this listener? As far as my knowledge goes it isn't really used by modders, I'd go with the Sim Instantiated one (forgot the specific name, find it on NRaas's Design and Discussion pages). In fact I think the differences between all the loadup events are not really known for now. But probably it's just me.
Code:
EventTracker.AddListener(EventTypeId.kHouseholdSelected, new ProcessEventDelegate(OnHouseholdChanged));
Is there a specific reason why you use this listener? As far as my knowledge goes it isn't really used by modders, I'd go with the Sim Instantiated one (forgot the specific name, find it on NRaas's Design and Discussion pages). In fact I think the differences between all the loadup events are not really known for now. But probably it's just me.
#5
22nd Aug 2015 at 4:24 AM
Posts: 299
Thanks: 1054 in 2 Posts
Quote: Originally posted by SimsMatthew
I'm not so familiar with how your mod works (as I haven't been following your another thread here) but I just noticed this:
Code:
EventTracker.AddListener(EventTypeId.kHouseholdSelected, new ProcessEventDelegate(OnHouseholdChanged)); Is there a specific reason why you use this listener? As far as my knowledge goes it isn't really used by modders, I'd go with the Sim Instantiated one (forgot the specific name, find it on NRaas's Design and Discussion pages). In fact I think the differences between all the loadup events are not really known for now. But probably it's just me. |
Oh, because I want it to check for stuff when the Active Household changes. I use that to re-set the roommate status and the number of roommates on each lot where it's enabled. If it doesn't check when it switches households, it doesn't work...
Instructor
#6
22nd Aug 2015 at 2:30 PM
Posts: 516
Thanks: 4225 in 14 Posts
By reading through your code more clearly:
1. Why do you define the interaction singletons OnPreLoad? Is there a specific reason?
2. I suddenly think about the problem I've talked about before: the world is "instantiated", but the objects / sims aren't, especially in big worlds. That means, OnWorldLoadFinished doesn't mean all your required targets are properly loaded. You may want to ensure an active household actually exists in a world using the method I've PM-ed you and then implement the rest of the stuff.
1. Why do you define the interaction singletons OnPreLoad? Is there a specific reason?
2. I suddenly think about the problem I've talked about before: the world is "instantiated", but the objects / sims aren't, especially in big worlds. That means, OnWorldLoadFinished doesn't mean all your required targets are properly loaded. You may want to ensure an active household actually exists in a world using the method I've PM-ed you and then implement the rest of the stuff.
#7
22nd Aug 2015 at 4:37 PM
Posts: 299
Thanks: 1054 in 2 Posts
Quote: Originally posted by SimsMatthew
By reading through your code more clearly: 1. Why do you define the interaction singletons OnPreLoad? Is there a specific reason? 2. I suddenly think about the problem I've talked about before: the world is "instantiated", but the objects / sims aren't, especially in big worlds. That means, OnWorldLoadFinished doesn't mean all your required targets are properly loaded. You may want to ensure an active household actually exists in a world using the method I've PM-ed you and then implement the rest of the stuff. |
To be honest, I was still new to all this back then, and I either copied it from a tutorial or someone here suggested I do that. Either way, that part works! Just not the alarms I have set up...
Who Posted
|