- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- How do I implement a condition whether sims have a custom trait?
- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- How do I implement a condition whether sims have a custom trait?
Replies: 2 (Who?), Viewed: 298 times.
#1
5th Nov 2022 at 12:22 AM
Posts: 268
Thanks: 1167 in 17 Posts
How do I implement a condition whether sims have a custom trait?
I recently completed Arsil's tutorial on how to make a custom trait. However, I find myself lost on how to utilize this new tool.Arsil's Custom Trait Tutorial
For my next project I wish to make a script mod which adds stretch marks to sims that have given birth. However, in real life not every individual inherets stretch marks. So, I wanted to make two custom hidden traits to act kind of like a DNA strand. One which will allow stretch marks to appear on sims after they have given birth and another which will filter out sims from getting stretch marks.
So, my question is how do I implement a condition for whether the sims have these custom traits?
I know in order to make a condition for the vanilla traits it goes like
Code:
if (sim.SimDescription.HasTrait(TraitNames.Insane) { EpicCodeApplies(sim) }
However, I'm not entirely sure how to use custom traits as a condition in this case. I would just like to add a condition for the sim to have the Stretch Mark DNA strand on the code below.
Code:
private static ListenerAction OnHadBaby(Event e) { if (e.Actor is Sim sim) { if (sim.IsFemale && sim.SimDescription.TeenOrAbove && (Genealogy.IsParent(sim.SimDescription.Genealogy, sim.SimDescription.Genealogy))) { Simulator.AddObject(new OneShotFunctionTask(() => Helpers.FemaleStretchMarksOutfitSwap(sim))); } } return ListenerAction.Keep; }
Any help would be appreciated. Thank you all.
Advertisement
Field Researcher
#2
6th Nov 2022 at 1:10 PM
To make HasTrait check for a custom instead of an EA trait, you just change from something like HasTrait(TraitNames.Insane) to HasTrait((TraitNames)hex-of-custom-trait) - for example, for the trait in Arsil's tutorial it'd be HasTrait((TraitNames)0x12DC32B0C3D9A022). It's the same for all the other cases I've found where you can add a custom entry to one of the game's enums: when you want to refer to it you write (name-of-enum)hex-of-custom-entry.
#3
6th Nov 2022 at 7:31 PM
Posts: 268
Thanks: 1167 in 17 Posts
Quote: Originally posted by lizcandor
To make HasTrait check for a custom instead of an EA trait, you just change from something like HasTrait(TraitNames.Insane) to HasTrait((TraitNames)hex-of-custom-trait) - for example, for the trait in Arsil's tutorial it'd be HasTrait((TraitNames)0x12DC32B0C3D9A022). It's the same for all the other cases I've found where you can add a custom entry to one of the game's enums: when you want to refer to it you write (name-of-enum)hex-of-custom-entry. |
Thank you so much lizcandor. I will give this a shot when I get the chance.
Who Posted
|