Modding Tutorials/PatchOperations

From RimWorld Wiki
Revision as of 01:44, 24 June 2017 by Maoman (talk | contribs)
Jump to navigation Jump to search

Modding Tutorials

Alpha 17 added a new RimWorld Modding feature, XML PatchOperations, that allow mods to edit specific elements of an xml def without overriding the other. This greatly reduces mod conflicts.

Here's a simple example of replacing the texture path for deep water:

  <Operation Class="PatchOperationReplace">
	<xpath>//TerrainDef[defName = "WaterDeep"]/texturePath</xpath>
	<value><texturePath>Your/Texture/Path/Here</texturePath></value>
  </Operation>


Resources

The best tutorial on PatchOperations created by Zhentar: Introduction to PatchOperation

You can also learn about XPaths here: XPath tutorial

There is also an Overview of PatchOperations on the RimWorldModGuide.


Why This Is Important

Previously, modders could overwrite an XML definition for a Thing. When another Mod tried to overwrite the same Thing in XML, the previous Mod would break. This caused a Mod conflict. With PatchOperations, each mod now only changes specific elements of the XML, leaving the XML Thing untouched otherwise. This is a boon to Modders.