Probably a simple issue with xpath

Started by Sixdd, June 07, 2017, 12:33:31 PM

Previous topic - Next topic

Sixdd

Hey all, I'm having a hard time getting what I thought was a simple xpath operation to work. code below:
<Operation Class="PatchOperationInsert">
<xpath>*/ThingDef[defName="Campfire"]/comps/li[@Class="CompProperties_Refuelable"]/fuelFilter/thingDefs/li</xpath>
<value>
<li>WoodBirch</li>
<li>WoodCecropia</li>
<li>WoodOak</li>
<li>WoodPine</li>
<li>WoodPoplar</li>
<li>WoodSaguaro</li>
<li>WoodTeak</li>
<li>WoodEbony</li>
<li>WoodAmaranth</li>
<li>WoodWillow</li>
<li>WoodMaple</li>
<li>WoodCherry</li>
<li>WoodCamellia</li>
<li>WoodAcacia</li>
<li>WoodPalm</li>
</value>
</Operation>

<Operation Class="PatchOperationSequence">
<success>Always</success>
<Operations>
<li Class="PatchOperationTest">
<xpath>*/ThingDef[defName="Bamboo"]</xpath>
<!-- <success>Invert</success> -->
</li>
<li Class="PatchOperationInsert">
<xpath>*/ThingDef[defName="Campfire"]/comps/li[@Class="CompProperties_Refuelable"]/fuelFilter/thingDefs/li</xpath>
<value>
<li>Bamboo</li>
</value>
</li>
<li Class="PatchOperationInsert">
<xpath>*/ThingDef[defName="FueledStove"]/comps/li[@Class="CompProperties_Refuelable"]/fuelFilter/thingDefs/li</xpath>
<value>
<li>Bamboo</li>
</value>
</li>
</Operations>
</Operation>


Now the problem with this is that when I try to refuel the campfire it says it's lacking ingredients, but if I have bamboo it refuels just fine. I tried with every wood type and bamboo is the only one registering in the list. Is this an Insert operation quirk or did I miss something totally obvious?

~Six


EDIT: I decided to try using Add operations again and it works now. The odd thing is though that one of my colonists is refusing to refuel the campfire, even though he isn't incapable of anything, where the other three can all refuel just fine. Not sure where the problem is but I'll reply here if I figure it out.

jamaicancastle

Add and Insert have different behaviors. Basically, the patch operation uses the <xpath> path to find a node in the loaded XML. Then Add creates a child of that node, whereas Insert creates a sibling of that node. Other than that I can't think of what might be presenting a problem here.

Unrelated to that - have you tried seeing if the fuelFilter will take thingCategories instead of/in addition to thingDefs, the way other filters will? It seems like a single entry for the "Woody" category should collect all of the different woods.

Sixdd

I tried that in A16 but it didn't work. As far as the xml autodoc is concerned it doesn't work.