My graphic mod is conflicting with another mod. Without the other mod, I need to ADD graphic information for the texture. When the other mod is installed, the ADD produces and error, so I have to use REPLACE. I tried searching for a CONDITIONAL solution, and came up with the code below (but it doesn't work).
Please let me know what I am doing wrong...
<li class="PatchOperationConditional">
<xpath>*/ThingDef[defName = "ExoskeletonSuit"]/graphicData/texPath</xpath>
<nomatch Class="PatchOperationAdd">
<success>Always</success>
<xpath>Defs/ThingDef[defName = "ExoskeletonSuit"]</xpath>
<value>
<graphicData>
<texPath>Things/Item/BodyPart/ExoskeletonSuit</texPath>
<graphicClass>Graphic_Single</graphicClass>
<drawSize>0.80</drawSize>
</graphicData>
</value>
</nomatch>
<match Class="patchOperationReplace">
<success>Always</success>
<xpath>Defs/ThingDef[defName = "ExoskeletonSuit"]/graphicData/texPath</xpath>
<value>
<texPath>Things/Item/BodyPart/ExoskeletonSuit</texPath>
</value>
</match>
</li>
Anyone out there good with xpathing?
I tried using the <match></match> and <nomatch></nomatch> tags to designate the conditional for the xpath... but that obviously didn't work how I intended.
Any help?
remove the <success>Always</success>
and you'll at least get some hints on why/where/if it's failing.
Below is part of the log...
QuoteXML error: <xpath>*/ThingDef[defName = "ExoskeletonSuit"]/graphicData/texPath</xpath> doesn't correspond to any field in type PatchOperation. Context: <li class="PatchOperationConditional"><xpath>*/ThingDef[defName = "ExoskeletonSuit"]/graphicData/texPath</xpath><nomatch Class="PatchOperationAdd"><xpath>Defs/ThingDef[defName = "ExoskeletonSuit"]</xpath><value><graphicData><texPath>Things/Item/BodyPart/ExoskeletonSuit</texPath><graphicClass>Graphic_Single</graphicClass><drawSize>0.80</drawSize></graphicData></value></nomatch><match Class="patchOperationReplace"><xpath>Defs/ThingDef[defName = "ExoskeletonSuit"]/graphicData/texPath</xpath><value><texPath>Things/Item/BodyPart/ExoskeletonSuit</texPath></value></match></li>
Seems like it is saying that the path doesn't exist... um, but that is part of the condition. If it "matches", then show X ... it "nomatch" then do Y. Any idea how to fix this?
You've got a patchOperationReplace there. XML is case sensitive.
That didn't solve the issue...
QuoteXML error: <xpath>*/ThingDef[defName = "ExoskeletonSuit"]/graphicData/texPath</xpath> doesn't correspond to any field in type PatchOperation. Context: <li class="PatchOperationConditional"><xpath>*/ThingDef[defName = "ExoskeletonSuit"]/graphicData/texPath</xpath><nomatch Class="PatchOperationAdd"><success>Always</success><xpath>Defs/ThingDef[defName = "ExoskeletonSuit"]</xpath><value><graphicData><texPath>Things/Item/BodyPart/ExoskeletonSuit</texPath><graphicClass>Graphic_Single</graphicClass><drawSize>0.80</drawSize></graphicData></value></nomatch><match Class="PatchOperationReplace"><success>Always</success><xpath>Defs/ThingDef[defName = "ExoskeletonSuit"]/graphicData/texPath</xpath><value><texPath>Things/Item/BodyPart/ExoskeletonSuit</texPath></value></match></li>
Post the entire xml, from <Patch> to </Patch>
I posted a text file with the complete xml...
http://classicgaming.cc/temp/MedPatches.txt (http://classicgaming.cc/temp/MedPatches.txt)
It isn't because the class assertion prior to PatchOperationConditional has a lower case "c"?
Otherwise, maybe take it out of the Patch sequence as a standalone operation to see if that's the issue?
Or possibly lowercase 'p'?
Quote from: Pelador on February 04, 2019, 07:30:54 PM
It isn't because the class assertion prior to PatchOperationConditional has a lower case "c"?
Otherwise, maybe take it out of the Patch sequence as a standalone operation to see if that's the issue?
This works fine... (but wont work when I have a mod conflict)
Quote<li Class="patchOperationAdd">
<success>Always</success>
<xpath>Defs/ThingDef[defName = "ExoskeletonSuit"]</xpath>
<value>
<graphicData>
<texPath>Things/Item/BodyPart/ExoskeletonSuit</texPath>
<graphicClass>Graphic_Single</graphicClass>
<drawSize>0.80</drawSize>
</graphicData>
</value>
</li>
... it's when I add the conditional that there is an issue...
Quote from: LWM on February 04, 2019, 08:53:13 PM
Or possibly lowercase 'p'?
I followed the guide on rimworldwiki ... PatchOperationConditional (with caps)
https://rimworldwiki.com/wiki/Modding_Tutorials/PatchOperations#PatchOperationConditional (https://rimworldwiki.com/wiki/Modding_Tutorials/PatchOperations#PatchOperationConditional)
Your conditional XML has <li class="PatchOperationConditional">. Instead of <li Class="...">.
Quote from: LWM on February 06, 2019, 11:31:45 AM
Your conditional XML has <li class="PatchOperationConditional">. Instead of <li Class="...">.
Wow. I can officially say that I hate programming. No wonder why I stick to the design side of things. That seems to be working... Let me run through the rest of the mod (and add a ton of other conditionals). Thanks.
Getting a minor case mismatch between xml and c# is not exactly the most fun part of modding; you're not alone in hitting your head against that one for a while. At least there's that?