XPath Patch Failing

Started by SihvMan, May 18, 2017, 01:13:12 AM

Previous topic - Next topic

SihvMan

I need some help.

I am attempting to use the new A17 xpath patching method to replace the tusk that drops when butchering elephants. However, each time I try it, it kicks out a red error message with a hard to understand error log.

Here's the code I'm using to patch;


<?xml version="1.0" encoding="utf-8" ?>

<Patch>

  <Operation Class="PatchOperationReplace">
  <xpath>//PawnKindDef[defName = "Elephant"]/butcherBodyPart</xpath>
  <value>
        <butcherBodyPart>
          <bodyPartGroup>HeadAttackTool</bodyPartGroup>
  <thing>SkeletonElephant_minified</thing>
        </butcherBodyPart>
  </value>
  </Operation>

</Patch>



[Bones Mod] Patch operation Verse.PatchOperationReplace(//AnimalKindBase[defName = "Elephant"]/butcherBodyPart) failed
Verse.Log:Error(String) (at C:\Dev\RimWorld\Assets\Scripts\Verse\Utility\Debug\Log\Log.cs:48)
Verse.PatchOperation:Complete(String) (at C:\Dev\RimWorld\Assets\Scripts\Verse\Mods\PatchOperation.cs:62)
Verse.LoadedModManager:LoadAllActiveMods() (at C:\Dev\RimWorld\Assets\Scripts\Verse\Mods\LoadedModManager.cs:84)
Verse.PlayDataLoader:DoPlayLoad() (at C:\Dev\RimWorld\Assets\Scripts\Verse\Defs\Databases\PlayDataLoader.cs:92)
Verse.PlayDataLoader:LoadAllPlayData(Boolean) (at C:\Dev\RimWorld\Assets\Scripts\Verse\Defs\Databases\PlayDataLoader.cs:32)
Verse.Root:<Start>m__858() (at C:\Dev\RimWorld\Assets\Scripts\Verse\Global\Root\Root.cs:49)
Verse.LongEventHandler:RunEventFromAnotherThread(Action) (at C:\Dev\RimWorld\Assets\Scripts\Verse\Global\LongEventHandler.cs:439)
Verse.LongEventHandler:<UpdateCurrentAsynchronousEvent>m__856() (at C:\Dev\RimWorld\Assets\Scripts\Verse\Global\LongEventHandler.cs:353)

Fluffy (l2032)

I'm pretty sure the butcherBodyPart is in the lifestages, so you're missing a few steps in your xpath.

Don't have code on hand to check at the moment, so can't point out the specific mistake/give an example.

SihvMan

Quote from: Fluffy (l2032) on May 18, 2017, 04:36:16 AM
I'm pretty sure the butcherBodyPart is in the lifestages, so you're missing a few steps in your xpath.

That was it. I needed it to be

<Patch>

  <Operation Class="PatchOperationReplace">
    <xpath>//PawnKindDef[defName = "Elephant"]/lifeStages/li/butcherBodyParts
    <value>
      <butcherBodyPart>
        <bodyPartGroup>HeadAttackTool</bodyPartGroup>
        <thing>SkeletonElephant_minified</thing>
      </butcherBodyPart>
    </value>
  </Operation>

</Patch>

instead.