- Site Map >
- Modding and Creation >
- Sims 4 Creation >
- Modding Discussion >
- Adding a Trait to Club Requirements Selection (Scripted)
- Site Map >
- Modding and Creation >
- Sims 4 Creation >
- Modding Discussion >
- Adding a Trait to Club Requirements Selection (Scripted)
Replies: 0 (Who?), Viewed: 2841 times.
#1
18th Aug 2018 at 7:47 PM
Posts: 2,671
Thanks: 62690 in 190 Posts
Adding a Trait to Club Requirements Selection (Scripted)
Certainly a custom trait can be added to the membership requirements list by altering the club.club_tuning module tuning, but since only one mod can override an XML resource that is somewhat limiting. Any simple list is generally fairly easy to modify via a script though, so I thought I'd look at how to perform this in a script so that any trait can modify that list without interfering with other mods.NOTE - You should probably warn your players: If a custom trait (or skill) requirement is added to a club, and the mod containing that trait is removed from the game, the club will eject all members and become unmodifiable. Even attempting to remove the club will result in the game hanging. This bug has been reported to EAxis. The only choice to fix this for the player is to add the mod back to the game so that they may use or remove the club.
So, on to the code. This adds the Never Weary trait to the list of selectable club membership requirements as an example:
Code:
import services import clubs.club_tuning import sims4.resources from sims4.tuning.instance_manager import InstanceManager from sims4.resources import Types from injector import inject_to TRAIT_NEVER_WEARY = 26392 # Note - This function should not be called prior to all trait tuning being # loaded into the game. It can be used any time after that. # Probably easiest to just use the method of injecting to the # load_data_into_class_instances method of the InstanceManager as # demonstrated in this example. def add_trait_to_club_traits_list(trait_instance_id): # Get the tuned instance of the trait we want to add instance_manager = services.get_instance_manager(Types.TRAIT) key = sims4.resources.get_resource_key(trait_instance_id, Types.TRAIT) trait_tuning_instance = instance_manager.get(key) if trait_tuning_instance: # Get the frozenset that has the current trait list available for clubs club_trait_tuning = clubs.club_tuning.ClubTunables.CLUB_TRAITS # Convert that to a list club_trait_list = list(club_trait_tuning) # Add the desired trait to the list club_trait_list.append(trait_tuning_instance) # Convert back to a frozenset, and overwrite the CLUB_TRAITS tuning club_trait_tuning = frozenset(club_trait_list) clubs.club_tuning.ClubTunables.CLUB_TRAITS = club_trait_tuning @inject_to(InstanceManager, 'load_data_into_class_instances') def _load_club_trait_tuning(original, self): original(self) if self.TYPE == Types.TRAIT: add_trait_to_club_traits_list(TRAIT_NEVER_WEARY)
Who Posted
|