RimWorld

RimWorld

Softness Control for Soft Warm Beds
 This topic has been pinned, so it's probably important
cyanobot  [developer] 5 Jul, 2024 @ 4:08am
Guide: Overriding Softness
This mod allows you to override the Soft Warm Beds' Softness calculation by specifying a value for the Textile_Softness stat directly in the xml for any fabric.

Reasons you might want to override a softness value:
- you don't like the numbers I've picked
- you want to add a value for a textile I haven't patched
- you're making your own textile-adding mod
- other

The Short Version
For those who already know their way around the xml.

Textile_Softness is a new stat added by Soft Warm Beds. Without Softness Control, Soft Warm Beds auto-generates the values for Textile_Softness, ignoring anything specified in the xml.

With Softness Control you can specify Textile_Softness directly in the <statBases> for a fabric, and Soft Warm Beds is told to skip over any that already have a value.

If you're overriding my values you'll want to load after Softness Control.

(Bear in mind whether you're Adding to a textile that doesn't yet have an entry for Textile_Softness, or Replacing one I've already added.)

Method 0: ask me
If you want a patch included for a mod that isn't on my list, go ahead and ask. If you think I'm wrong about what a value should be, tell me so and why. I might disagree, but I might not.

Pros:
- very low effort
- others might also benefit from the inclusion of more mods

Cons:
- I might disagree with a suggested change
- have to wait for me to get round to it

Method 1: edit this mod's xml
If you want to override a value I've set for vanilla textures or any of the mods I have patched for, you can just edit my xml.
  1. Find the files for this mod. From the Rimworld main menu, hit Mods. Select Softness Control from the list. Click Advanced -> Open Folder. That should open up the mod folder in your file explorer.
  2. Find the file containing the textile you want to edit. They're all in the Patches folder, sorted by mod. For vanilla fabrics you want vanilla_softness.xml, etc.
  3. Open it in your text editor of choice. (I recommend Notepad++, but any text editor will do.)
  4. Scroll down or search (Ctrl+F on Windows, usually) for the entry that mentions the textile you're looking for.

    They're referenced by defName, which might not be quite the same as the name you see in game, but they're usually pretty similar.

    The snippet you're looking for looks something like this for a vanilla fabric:
    <Operation Class="PatchOperationAdd"> <xpath>Defs/ThingDef[defName="DevilstrandCloth"]/statBases</xpath> <value> <Textile_Softness>0.4</Textile_Softness> </value> </Operation>
    or this for a mod fabric:
    <li Class="PatchOperationAdd"> <xpath>Defs/ThingDef[defName="VAEWaste_ToxicLeather"]/statBases</xpath> <value> <Textile_Softness>0.24</Textile_Softness> </value> </li>
  5. Change the numerical value to what you'd prefer it to be. 0.4 = 40%, etc.
  6. Save the file. Make sure it saves as a .xml.
  7. Either restart RimWorld or use the dev option "Hot reload Defs".

Pros:
- pretty quick and straightforward

Cons:
- might get overridden when this mod updates and/or interfere with this mod updating
- your changes are mixed in with mine and might be hard to find/remember

Method 3: Make your own mini mod
The less hack-y and more stable alternative to Method 2. It takes a little more work, especially if you haven't made a mod before, but I promise it's actually pretty simple.

The Rimworld wiki[rimworldwiki.com] contains some pretty good tutorials for basic modding and I won't replicate all of that here.
For this tiny mod you won't need very much of the tutorial content. You will need:
  • Mod Folder Structure[rimworldwiki.com] - Tells you where to put your mod files, and how to lay them out. The only subfolders you'll need are About and Patches.
  • About file[rimworldwiki.com] - You need one of these for Rimworld to find and read your mod.
  • PatchOperations[rimworldwiki.com] - How you actually make changes to textile stats.

I'd highly recommend both Notepad++ and the XML Tools plugin for it, but you can make xml in any text editor. Just be sure that you save as .xml files, not .txt or something else.

About.xml
Make Softness Control a dependency:
<modDependencies> <li> <packageId>cyanobot.softnesscontrol</packageId> <displayName>Softness Control for Soft Warm Beds</displayName> <steamWorkshopUrl>steam://url/CommunityFilePage/3211326812</steamWorkshopUrl> </li> <modDependencies>
If you are editing a textile from another mod, make that mod a dependency as well. It needs its own <li> entry, which goes inside <modDependencies> alongside the one above.

Also add Softness Control to the <loadAfter> tag. Your mod needs to load after Softness Control because it's overriding it.
<loadAfter> <li>cyanobot.softnesscontrol</li> </loadAfter>

Patches
Refer to the tutorials.

If you are overriding a value I've already added, you'll want PatchOperationReplace. If you're adding a value that I haven't touched, you'll want PatchOperationAdd.

Pros:
- separate from this mod so you can easily see and edit your own changes separate from mine
- won't be affected by updates to this mod
- if you want, you can publish it to Steam for other people to also benefit from your work

Cons:
- a bit more work

Method 4: If you're making a mod that adds textiles...
... and you want to specify a softness value for your textile.

Add the following line (with your desired softness value, doesn't have to be 0.5!) under the <statBases> node, along with all the other stats like comfort, etc.
<Textile_Softness MayRequire="cyanobot.softnesscontrol">0.5</Textile_Softness>
Last edited by cyanobot; 5 Jul, 2024 @ 5:16am