NQualityOfLife.XML.PatchIfExists - Niilo007/RimWorld-NQoL GitHub Wiki

PatchIfExists

Related:


XML

<Operation Class="NQualityOfLife.XML.PatchIfExists">
    <xpath>string</xpath>
    <probe>string</probe>
    <toVar>string</toVar> <!-- Optional -->
    <count>string</count> <!-- Optional -->
    <exists Class="PatchOperation"/>
    <doesNotExist Class="PatchOperation"/>
    <bothExist Class="PatchOperation"/>
    <onlyProbeExists Class="PatchOperation"/>
    <onlyXpathExists Class="PatchOperation"/>
    <bothDoNotExist Class="PatchOperation"/>
    <oneOrBothMissing Class="PatchOperation"/>
    <done Class="PatchOperation"> <!-- Optional -->

    </done>
    <error Class="PatchOperation"> <!-- Optional -->

    </error>
</Operation>

Usage

  • If <toVar> is provided, the given <xpath> is saved to it.
    • Variable names must begin and end with '{' & '}'

Errors


Examples

Used In Example:

<Operation Class="NQualityOfLife.XML.PatchIfExists">
    <xpath>Defs/ResearchProjectDef[label[contains(text(),"gunsmithing")] or defName="Gunsmithing"]/prerequisites/li[text()="Machining"]</xpath>
    <exists Class="PatchOperationRemove">
        <xpath>Defs/ResearchProjectDef[label[contains(text(),"gunsmithing")] or defName="Gunsmithing"]/prerequisites/li[text()="Machining"]</xpath>
    </exists>
    <doesNotExist Class="NQualityOfLife.XML.Log">
        <warning>Tried to remove 'Machining' from the 'prerequisites' of 'Gunsmithing' but it was not there! A conflicting research overhaul mod may be active.</warning>
    </doesNotExist>
</Operation>

Used In Example:

<Operation Class="NQualityOfLife.XML.PatchIfExists">
    <xpath>Defs/ResearchProjectDef[tab="VanillaExpanded"]</xpath>
    <probe>Defs/ResearchTabDef[defName="VanillaExpanded"]</probe>
    <onlyProbeExists Class="PatchOperationRemove">
        <xpath>Defs/ResearchTabDef[defName="VanillaExpanded"]</xpath>
    </onlyProbeExists>
</Operation>

Used In Example:

<Operation Class="NQualityOfLife.XML.PatchIfExists">
    <xpath>Defs/ResearchProjectDef[defName="VHGE_GasExtraction"]</xpath>
    <probe>Defs/ResearchProjectDef[defName="Electricity"]</probe>
    <bothExist Class="NQualityOfLife.XML.AddDeep">
        <xpath>Defs/ResearchProjectDef[defName="Electricity"]</xpath>
        <value>
            <prerequisites/>
        </value>
        <deepValue>
            <li>VHGE_GasExtraction</li>
        </deepValue>
    </bothExist>
    <onlyProbeExists Class="NQualityOfLife.XML.AddDeep">
        <xpath>Defs/ResearchProjectDef[defName="Electricity"]</xpath>
        <value>
            <prerequisites/>
        </value>
        <deepValue>
            <li>Smithing</li>
        </deepValue>
    </onlyProbeExists>
    <bothDoNotExist Class="NQualityOfLife.XML.Log">
        <error>Both: 'Electricity' and 'VHGE_GasExtraction' were missing!</error>
    </bothDoNotExist>
</Operation>

⚠️ **GitHub.com Fallback** ⚠️