Editing Modding Tutorials/PatchOperations

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 674: Line 674:
 
* Always - This patch operation always succeeds, i.e. it suppresses all errors that might have occurred. This used to be used in PatchOperationSequence along with PatchOperationTest in order to conditionally run patches, but is now obsolete.
 
* Always - This patch operation always succeeds, i.e. it suppresses all errors that might have occurred. This used to be used in PatchOperationSequence along with PatchOperationTest in order to conditionally run patches, but is now obsolete.
 
* Normal - Errors are handled normally
 
* Normal - Errors are handled normally
* Invert - Errors are considered a success and success is considered a failure. This used to be used in PatchOperationSequences to test the negative of a PatchOperationTest; you should now use <code><nomatch></code> on PatchOperationConditional.
+
* Invert - Errors are considered a success and success is considered a failure. This used to be used in PatchOperationSequences to test the negative of a PatchOperationTest; you should now use <code><nomatch></code> on PatchOperationConditional
 
* Never - This patch operation always fails. Generally only used in testing to see if a Sequence is working correctly, should never be used in published mods.
 
* Never - This patch operation always fails. Generally only used in testing to see if a Sequence is working correctly, should never be used in published mods.
 
=== Extenuating circumstances for "Success" ===
 
There are, in very specific circumstances, a valid reason to use a <code><success>Always</success></code> statement.
 
 
For instance, consider the following opening lines for a Patch: <code>
 
<Operation Class="PatchOperationConditional">
 
<xpath>/Defs/JoyKindDef[defName="Sierra_Drinking_Milkshake"]</xpath>
 
<match Class="PatchOperationReplace">
 
<success">Always</success>
 
<xpath>/Defs/ThingDef[defName = "Laban" or defName = "AmbrosiaLaban" or defName = "ChocolateLaban" or defName = "StrawberryLaban" or defName = "MedicinalLaban"]/ingestible/joyKind</xpath>
 
<value>
 
<joyKind>Sierra_Drinking_Milkshake</joyKind>
 
</value>
 
</match>
 
</Operation>
 
</code>
 
 
This Patch detects if a specific Mod's Joy Kind Def exists and, if it does, changes the Recreation Type received by consuming a Thing Def from another Mod; the Patch exists in neither Mod's folder, coming from a third-party Mod that is completely separate.
 
 
"Sierra Drinking Milkshake" (<code>"Sierra_Drinking_Milkshake"</code>) is added by the [https://steamcommunity.com/sharedfiles/filedetails/?id=2595980371 Milkshake Digital Deluxe Mod], and Laban (<code>"Laban"</code>) is added by the [https://steamcommunity.com/sharedfiles/filedetails/?id=2595938070 Laban Mod].
 
 
Now, imagine that neither the author of the Laban Mod or the Milkshake Mod created this Patch. Instead, a fan of both Mods included this in a compilation of Patches that alters dozens of Mods.
 
 
This Patch is in a third-party Mod that is neither of the constituent Mods that it patches. If a player had the Milkshake Mod loaded loaded, but ''did not'' have the Laban Mod, this Patch would attempt to to change the Joy Kind Def of consuming Laban to something that does not exist, and would cause the Laban Thing Def to cause errors when consumed, ''and'' cause the Patch to fail.
 
 
Therefore, because a large third-party Patch has to patch two Mods that it is not integrated with directly, and uploading a single Patch as a single Mod versus a compilation is inefficient, then it must be concluded that using "<code><success>Always</success></code>" '''''is acceptable in this extenuating circumstance'''''.
 
 
Outside of situations like this, using the "Success" statement is still not recommended.
 
  
 
== Tips and Tricks ==
 
== Tips and Tricks ==

Please note that all contributions to RimWorld Wiki are considered to be released under the CC BY-SA 3.0 (see RimWorld Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)