RimWorld

RimWorld

Soybeans
Penultimate_Jive  [developer] 10 May, 2024 @ 6:12pm
Mod Patching Tutorial + Example
You can edit any values in a mod by implementing patches.
A patch is an independent mod, and will not be affected by updates of the original mod.


To make a patch mod, you need a folder containing:
  • an About folder with About.xml
  • a Patches folder with Patch.xml
Patch Structure Example:
Soybeans Patch ├┬About │└─About.xml └┬Patches └─Patch.xml

The About.xml file contains the title, and description that you see in the mod menu.
It should look like this:
<?xml version="1.0" encoding="utf-8"?> <ModMetaData> <name>Soybeans Patch</name> <author>Mr. Patch Maker</author> <packageId>mrpatchmaker.soybeanspatch</packageId> <supportedVersions> <li>1.5</li> </supportedVersions> <description>This is my patch for the Soybeans mod.</description> <modDependenciesByVersion> <v1.5> <li> <packageId>penultimatejive.soybeans</packageId> <displayName>Soybeans</displayName> <steamWorkshopUrl>https://gtm.steamproxy.vip/workshop/filedetails/?id=932373937</steamWorkshopUrl> </li> </v1.5> </modDependenciesByVersion> </ModMetaData>

The patch.xml file is what causes changes in the mod.
It should look like this:
<?xml version="1.0" encoding="utf-8" ?> <!-- This is a comment, nothing here will affect the code. KEY: JLDrzbPQzy = Soybean Plant --> <Patch> <Operation Class="PatchOperationConditional"> <xpath>Defs/ThingDef[defName="JLDrzbPQzy"]</xpath> <match Class="PatchOperationReplace"> <xpath>Defs/ThingDef[defName="JLDrzbPQzy"]/plant/growDays</xpath> <value> <growDays>2.14</growDays> </value> </match> </Operation> </Patch>

This example operation will change the amount of time the Soybean plant takes to grow.
You can add more operations within <Patch> </Patch>.

To find any values, or names from a mod to change; in your file explorer, go to "Steam:\steamapps\workshop\content\workshop\294100\932373937"
"932373937" is the folder that the Soybeans mod is located.
The id of any mod can be found in the URL of the workshop page.


With your patch complete, you can put your Soybeans Patch folder in your Rimworld mods folder "Steam:\steamapps\common\RimWorld\Mods"

This example is available for download from my GitHub https://github.com/jacobeman5872/Rimworld-XML-Patch-Example
Last edited by Penultimate_Jive; 10 May, 2024 @ 6:13pm