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 21st Oct 2020 at 5:38 AM
Trait XML Instance Help
Hi! I am trying to write a script in python to apply the clumsy trait to the active sim. I used this thread as the basis (I test the code that scumbumbo wrote and everything worked as expected). I changed the xml instance code to the one for clumsy and re-ran the code and nothing happened. The outputs showed up, but the trait was not applied to the sim. I think that I am using the wrong xml instance id (I am honestly unsure of what the name for the code is).

I got the number by searching for "trait_Clumsy" in the xml file finder and using the number listed under "instance" which is 16832 is that the right number? Do I have to do something special to add in a 4th "normal" trait?
Screenshots
Advertisement
Lab Assistant
#2 Old 21st Oct 2020 at 10:58 AM
I believe you need to remove a personality trait before you can add another.
This function in the TraitTracker class seems to be blocking the addition of a 4th personality trait:
Code:
    def can_add_trait(self, trait):
        if not self._has_valid_lod(trait):
            return False
        if self.has_trait(trait):
            logger.info('Trying to equip an existing trait {} for Sim {}', trait, self._sim_info)
            return False
        if trait.is_personality_trait and self.empty_slot_number == 0:
            logger.info('Reach max equipment slot number {} for Sim {}', self.equip_slot_number, self._sim_info)
            return False
        if not trait.is_valid_trait(self._sim_info):
            logger.info("Trying to equip a trait {} that conflicts with Sim {}'s age {} or gender {}", trait, self._sim_info, self._sim_info.age, self._sim_info.gender)
            return False
        elif self.is_conflicting(trait):
            logger.info('Trying to equip a conflicting trait {} for Sim {}', trait, self._sim_info)
            return False
        return True


specifically this part:
Code:
if trait.is_personality_trait and self.empty_slot_number == 0:
    logger.info('Reach max equipment slot number {} for Sim {}', self.equip_slot_number, self._sim_info)
    return False


You would have to get the sim's personality traits and remove one of them before you can add another.
Here is a fully working example of a 'clumsy' and 'unclumsy" cheat which adds or removes the clumsy trait.
Test Subject
Original Poster
#3 Old 21st Oct 2020 at 11:58 PM
Oh wow thank you so much!! This is exactly what I was looking for! Can the death by anger trait be added because it is not a "standard trait"? Other mods like the slice of life personality analyzer also add a 4th custom trait to a premade sim do you think that when the creator made those new traits she categorized them as a "special traits" so they can be added after the sim is created?
Lab Assistant
#4 Old 22nd Oct 2020 at 3:29 AM
Quote: Originally posted by 13pigpen
Oh wow thank you so much!! This is exactly what I was looking for! Can the death by anger trait be added because it is not a "standard trait"? Other mods like the slice of life personality analyzer also add a 4th custom trait to a premade sim do you think that when the creator made those new traits she categorized them as a "special traits" so they can be added after the sim is created?


The death by anger trait is a "ghost" trait (gives the sim the shader effect) so it can be added because only personality traits use up the 3 personality trait slots.

Usually, mod creators set their traits as "gameplay" traits or "hidden" traits, depending on if they want the trait to be visible or not.
Gameplay traits are stuff like the trait rewards from the rewards store and the trait rewards from completing aspirations. They're traits added through gameplay, so the game does not limit how many you can have.
Hidden traits are... hidden. They're not visible in the ui. They're stuff like the occult traits, species traits, age traits, and gender traits.

The trait tracker only enforces the 3 trait limit on personality traits, so you can add as many "gameplay" and "hidden" traits to a sim as you want.
Test Subject
Original Poster
#5 Old 22nd Oct 2020 at 4:17 AM
that makes sense. The type of trait would then be specified in the xml code for the trait right?
Lab Assistant
#6 Old 22nd Oct 2020 at 9:33 AM
Quote: Originally posted by 13pigpen
that makes sense. The type of trait would then be specified in the xml code for the trait right?

It's specified in 2 places.

The first is in the xml tuning for the trait and looks like this:
Code:
<E n="trait_type">GAMEPLAY</E>

The second is in the trait's "sim data" file and looks like this:
Code:
<T name="trait_type">1</T>

Personality traits have PERSONALITY as their trait type in the xml file, with 0 as their trait type in their simdata file.

You can extract a trait's tuning with Sims 4 Studio to get both the xml tuning and sim data tuning into a package file to look at.
Back to top