Skip to content

Mod #1 - CAS Trait

Finally. Finally. Let’s make our first mod.

We’re going to make a simple trait mod. The trait won’t actually do anything for now other than appear in CAS, but we’ll give it a custom name, description, and icon to show how resource linking works.

While it is possible to write tuning XML from scratch, we’ll be using tdesc.lot51.cc to get started since it is much easier when learning and will handle SimData syncing for us.

Firsts, let’s set up a new tdesc editor.

  1. Head to tdesc.lot51.cc.
  2. If the sidebar on the left isn’t open, click the icon in the top left of the page to toggle it.
  3. Search trait, then select Traitsfolder, then select Trait.
  4. This opens a new tuning editor tab.

The tuning builder can seem a bit overwhelming at first, so let’s take a quick tour.

At the top center of the editor, you can set your creator name, custom tuning name, and an optional DLC requirement. The DLC requirement is stored in the tuning resource key’s Group field.

Your creator name and tuning name are used to generate a unique tuning ID automatically, which is stored in the XML’s root node as the s attribute. We’ll look more at this later in case we ever need to do it manually.

Lot51 TDesc Trait

Below this is a UI for editing every possible field the current tuning supports, and on the right will be the final tuning XML. Explore the different buttons and icons. You can toggle nodes, expand list and object nodes, add values to lists, select references, and more.

If we look at the first node for a trait, we see animation_overlays has a type L for list. Expanding it, we see the list contains U nodes (objects), and each object has a single T field _overlay_animation (T is used for single values of any type).

Lot51 TDesc Trait

Clicking on any node will show the node’s description on the right, below the XML view.

Lot51 TDesc Trait

The final XML will appear on the right.

Lot51 TDesc Trait

A large part of learning how to mod is exploring tuning descriptions, reading about how things work, and just trying stuff out.

S4E also has a description browser that works offline (but doesn’t generate XML), as well as some other cool features for exploring game files that we’ll look at in the next tutorial. For now, let’s get back on track.

If you haven’t already, make sure to set your Creator Name and Tuning Name in the top center.

Now let’s add the minimum required fields to get our trait to show up in CAS.

  1. display_name - The name of the trait. Use 0x2D8777C7 for Awesome!
  2. trait_description - Tooltip description. Use 0x89F40002 for I trust in my awesomeness.
  3. ages - List of ages that can have the trait. Required for CAS.
  4. species - Species that can have this trait. Required for CAS. Add HUMAN.
  5. occults - Occults that can have the trait. Required for CAS. Add HUMAN.
  6. icon - The icon. Use 2f7d0004:00000000:cfc547bc4742a87a for trait_CoolGuy.png.
  7. tags - There are hundreds of tags for different things. We need to one to define the CAS trait category. Add one of the following:
    • TraitGroup_Emotional, TraitGroup_Hobbies, TraitGroup_Lifestyle, or TraitGroup_Social
    • TraitGroup_Emotional is first, so it’s easiest to test with

Here’s a look at the final XML:

<?xml version="1.0" encoding="utf-8"?>
<I c="Trait" i="trait" m="traits.traits" n="ZMilla:AwesomeTrait" s="1131508133">
<L n="ages">
<E>YOUNGADULT</E>
<E>ADULT</E>
<E>ELDER</E>
</L>
<T n="display_name">0x2D8777C7<!--Awesome!--></T>
<T n="icon" p="InGame\UI\Icons\CAS\Traits\trait_CoolGuy.png">2f7d0004:00000000:cfc547bc4742a87a</T>
<L n="occults">
<E>HUMAN</E>
</L>
<L n="species">
<E>HUMAN</E>
</L>
<L n="tags">
<E>TraitGroup_Emotional</E>
</L>
<T n="trait_description">0x89F40002<!--I trust in my awesomeness.--></T>
</I>

The name of your tuning is stored as in the root node’s n attribute. This can be set in Lot51 and should be in the format CreatorCreator:TuningName which is ZMilla:AwesomeTrait for me. The tuning’s ID is stored as an integer in the s attribute. This should be either the FNV32 or FNV64 of the tuning name.

Finally, to actually create the mod:

  1. In lot51.tdesc.cc, click Download Tuning AND Download SimData
  2. (Optional) In Sims 4 Editor, you can create a new empty environment for easier testing.
  3. In Sims 4 Editor, open the package editor, enable editing, then create a new package in your Mods folder
  4. Click Import and import both files from step 1, then save

That’s it! A working mod! Our package contains tuning XML that defines a new trait, points to existing game resources, and is backed by SimData.

And behold… our final masterpiece in game.

Awesome Trait


Having a working mod is awesome, and you should feel proud if you’ve made it this far. Congratulations!

There’s a small problem though… this mod just points to existing game data. That’s boring. Let’s fix it!

Let’s customize the trait’s name and description using string tables.

  1. In the S4E package editor, click Create and change the type to String Table.
  2. (Optional) When making a mod you plan to release, use the All Languages option to create linked tables for all languages.
  3. Select the English (or your native language) table, and click the + button to create new entires. New entries are added to all linked tables.
  4. Create two entries, one for the trait name, one for the description. String Table
  5. In both the XML and SimData resources, update the display_name and trait_description fields with the keys you just created. You can copy keys from the string table editor.
    • <T n="display_name">0xADFD2D36</T>
    • <T n="trait_description">0x02AEC635</T>
  6. You can delete the comments related to “Awesome” as they were documentation for the original references.

Because traits are sorted alphabetically, your trait will likely have moved in the list.

Radical Trait

Sims 4 supports several image types. The most common type is DDS, which in turn has many subtypes. This image format was made for the DirectX, but is supported by software like GIMP, Photoshop, S4E, and S4S. Trait thumbnails use DDS images with the DXT5/DST5 subtype. You don’t need anything else about images than this for the tuning tutorial, but there is a work in progress article about image types used by Sims 4.

We’ll export the image we’ve already been referencing, edit it, then reimport it with a new resource key.

  1. In the tuning XML, the icon field is a resource key. Copy the instance, which is cfc547bc4742a87a
  2. From the S4E homepage, open the Global Resource Browser, and search cfc547bc4742a87a.
  3. Right click the image and export to a DDS.
  4. Edit the image with an external program like GIMP or photoshop.

Since I’m a programmer and not an artist, I’ll hit it with the classic hue shift in GIMP and call it a day.

In the future, S4E will allow importing resources with any file name, but for the time being we need to add our desired resource key to the file name. This gives us an excuse to see how ID generation works.

Lot51 handled our tuning ID, S4E handled our string table IDs, now let’s generate our own ID for the image.

  1. On the S4E homepage, select Utility > Hash Utility.
  2. Input something completely unique. Suggestion: CreatorName:PackageName:FileName
  3. Copy the FNV64 hex value.

I’ll use ZMilla:AwesomeTrait:CoolGuy.png for an instance of 0xE7D367714A02CDB2, but use your own info for this step.

Recall that resource keys use the format Type:Group:Instance unless otherwise stated. DDS images have a type of 0x00B2D882 and the group is unused, so my final resource key is 0x00B2D882:0x00000000:0xE7D367714A02CDB2

However, file names don’t support :, so we need to replace those with ! as the next best thing. If using Sims 4 Studio, the file name needs to be the resource key only. When using Sims 4 Editor, the resource key can be anywhere in the file name, so my final file name will be CoolGuy-0x00B2D882!0x00000000!0xE7D367714A02CDB2.dds.

Finally, let’s import our edited, correctly named dds file.

  1. Click Import and select your edited DDS file.
  2. Update the icon field in the tuning XML and SimData with the new DDS resource key.
  3. Only the instance changed, so just editing the last part of the key is enough.
  4. The “path” node is purely documentation. You can change the value to store the image name, or remove it.

Example XML: <T n="icon">0x2f7d0004:0x00000000:0xE7FC3D714A258B10</T>

Finally, a fully customized tuning mod!

Radical Green Trait

I want to hammer in the fact that what we just did literally, making a trait, isn’t nearly as what we did conceptually. We added custom resources to a package, then made those resources reference each other using string keys and resource keys. Other resource types may also be referenced by string, tuning ID, or enum, but the concept remains the same.

That is the heart of Sims 4 modding. Even when making custom items or clothing, things like models, textures, and animations are just resources that can be referenced via resource key, and other resources like CASPart or CatalogObject do exactly that to define new objects!

It’s turtles resources, keys, and references all the way down.

I glossed over one major thing. With so many fields to choose from, how did I know which ones were required for a CAS trait? How do we figure out how stuff works in general?

The general answer is to find examples of existing files that do something similar to what you want as a starting point, then experiment. This will be the entire focus of the next tutorial.

The specific answer is that I found files for other CAS traits, looked for fields shared by many traits, then removed fields one by one until I had only required fields remaining.