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!
Lab Assistant
Original Poster
#1 Old 13th Sep 2014 at 7:11 AM
Default Adding traits.
I was looking through the Maxis scripts and found this little bugger:

Code:
In simulation/traits/trait_tracker.py:

    def add_trait(self, trait):
        if not self.can_add_trait(trait):
            return False
        self._equipped_traits.add(trait)
        self._add_buffs(trait)
        self._sim_info.resend_trait_ids()
        sim = self._sim_info.get_sim_instance()
        if sim is not None:
            with telemetry_helper.begin_hook(writer, TELEMETRY_HOOK_ADD_TRAIT, sim=sim) as hook:
                hook.write_int(TELEMETRY_FIELD_TRAIT_ID, trait.guid64)
            services.social_service.post_trait_message(self._sim_info, trait, added=True)
            services.get_event_manager().process_event(test_events.TestEvent.TraitAddEvent, sim_info=self._sim_info)
        return True


I'm guessing that to add a reward trait (for completing an aspiration) to a sim, I'd have to write "sim_info.trait_tracker.add_trait('SomeTrait')" in my code. The thing is that for some reason this doesn't work. I'm guessing that I'm missing something here?
Advertisement
Lab Assistant
#2 Old 13th Sep 2014 at 9:07 AM
Firstly, adding traits after completing an aspiration is not something you have to do manually, it is handled by the code already in place.
Secondly, "sim_info" is not likely a global variable and you have to figure out how to get the sims info of a specific sim.
Lab Assistant
Original Poster
#3 Old 13th Sep 2014 at 10:34 AM
Quote: Originally posted by Fogity
Firstly, adding traits after completing an aspiration is not something you have to do manually, it is handled by the code already in place.
Secondly, "sim_info" is not likely a global variable and you have to figure out how to get the sims info of a specific sim.


What I'm trying to do is add the aspiration's trait to the sim without having to complete the aspiration. I'm looking into other ways of making this mod so that it's not so clunky, though. I perhaps could accomplish the thing I want without having to add traits of any sort (i.e. tuning or setting global values to zero).
Lab Assistant
#4 Old 13th Sep 2014 at 4:40 PM
I think you would have to change the category of the aspiration from reward to personality, and there might be more to it than that.
Back to top