Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Test Subject
Original Poster
#1 Old 11th Dec 2018 at 5:41 PM
When are tuning mods loaded?
A while ago I wrote a python script which fixes compatibility problems with XML tuning files. Then I got distracted by other stuff. It's sitting on my desktop right now, looking lonely.

Now I'm thinking about having this script run whenever Sims 4 starts, and auto-fix the conflicting tuning files from the mods folder. I need to know if this is possible.

When are tuning mods loaded? Is it possible to have a script run before them, and delay their loading until it is finished if necessary?
Advertisement
Deceased
#2 Old 11th Dec 2018 at 8:32 PM
Well, I'm not sure what fixes you have in mind, so I suppose ymmv, but you want to wait until after tuning mods are loaded in order to alter them (otherwise there is nothing there to actually alter). This is typically done by injecting a method to the load_data_into_class_instances() method of the InstanceManager. The new method calls the original function and follows that with any changes that need to be made to those tuning instances. A lot of mods use this method to simply add to the super affordances list for an object tuning.

A relatively simple example of this would be what I do in my Unlisted Phone Numbers mod -- look at the unlisted_phones.py script of that mod. The EXCH_load_data_into_class_instances() method calls the original, and then makes a choice depending on what tuning types were just loaded. If snippet tunings were loaded, then a new friendly exchange numbers interaction is added to the friendly tuning snippet's super affordances. If object tunings were just loaded, then two new interactions to exchange and revoke phone numbers are added to the object_sim tuning's relationship panel affordances.

There's also a way more complex modification done in that same file to drama nodes. This is done by actually modifying the method to resolve drama participants and is done in this manner to ensure that the filter term we want to add to a sim_filter tuning is ONLY done for actual drama nodes, and not any other XML tunings that may utilize that same sim_filter. The code sticks our new filter term into the sim_filter tuning, runs the original _resolve_drama_participant() method, and then removes that filter term from the sim_filter before anything else tries to use it. This demonstrates that tuning can be changed "on-the-fly" while the game runs, when necessary.
Test Subject
Original Poster
#3 Old 11th Dec 2018 at 9:24 PM
Quote: Originally posted by scumbumbo
Well, I'm not sure what fixes you have in mind, so I suppose ymmv, but you want to wait until after tuning mods are loaded in order to alter them (otherwise there is nothing there to actually alter). This is typically done by injecting a method to the load_data_into_class_instances() method of the InstanceManager. The new method calls the original function and follows that with any changes that need to be made to those tuning instances. A lot of mods use this method to simply add to the super affordances list for an object tuning.

A relatively simple example of this would be what I do in my Unlisted Phone Numbers mod -- look at the unlisted_phones.py script of that mod. The EXCH_load_data_into_class_instances() method calls the original, and then makes a choice depending on what tuning types were just loaded. If snippet tunings were loaded, then a new friendly exchange numbers interaction is added to the friendly tuning snippet's super affordances. If object tunings were just loaded, then two new interactions to exchange and revoke phone numbers are added to the object_sim tuning's relationship panel affordances.

There's also a way more complex modification done in that same file to drama nodes. This is done by actually modifying the method to resolve drama participants and is done in this manner to ensure that the filter term we want to add to a sim_filter tuning is ONLY done for actual drama nodes, and not any other XML tunings that may utilize that same sim_filter. The code sticks our new filter term into the sim_filter tuning, runs the original _resolve_drama_participant() method, and then removes that filter term from the sim_filter before anything else tries to use it. This demonstrates that tuning can be changed "on-the-fly" while the game runs, when necessary.


I was going to say this isn't what I was looking for, but changing the tuning on-the-fly is actually a better idea than what I had. Thank you.
Back to top