Difference between revisions of "Modding Tutorials/PatchOperations"

From RimWorld Wiki
Jump to navigation Jump to search
(Here's a start)
 
Line 1: Line 1:
 +
{{BackToTutorials}}
 
{{UC}}
 
{{UC}}
In Alpha 17, a new feature to RimWorld Modding was added, and that was XML PatchOperations. It allows different mods to edit specific elements of an xml def without one overriding the other. Here's a simple example of replacing the texture path for deep water:
+
'''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:
 +
 
 
<pre>
 
<pre>
 
   <Operation Class="PatchOperationReplace">
 
   <Operation Class="PatchOperationReplace">
Line 8: Line 12:
 
</pre>
 
</pre>
  
There is currently a short tutorial on PatchOperations created by Zhentar: [https://gist.github.com/Zhentar/4a1b71cea45b9337f70b30a21d868782 Introduction to PatchOperation]
+
 
 +
= Resources =
 +
 
 +
The best tutorial on PatchOperations created by Zhentar: [https://gist.github.com/Zhentar/4a1b71cea45b9337f70b30a21d868782 Introduction to PatchOperation]
  
 
You can also learn about XPaths here: [https://www.w3schools.com/xml/xpath_intro.asp XPath tutorial]
 
You can also learn about XPaths here: [https://www.w3schools.com/xml/xpath_intro.asp XPath tutorial]
 +
 +
There is also an [https://github.com/roxxploxx/RimWorldModGuide/wiki/SHORTTUTORIAL:-DefPatches Overview of PatchOperations]  on the [https://github.com/roxxploxx/RimWorldModGuide/wiki 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.

Revision as of 14:28, 1 June 2017

Modding Tutorials
Template:UC 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.