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

AddDeep

Related:


XML

<Operation Class="NQualityOfLife.XML.AddDeep">
    <xpath>string</xpath>
    <toVar>string</toVar> <!-- Optional -->
    <count>string</count> <!-- Optional -->
    <value>

    </value>
    <deepValue>

    </deepValue>
    <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 '{' & '}'

xpath

Used to select the matching nodes that you wish to add the deepValue to. Supports variables.


applyVariables

Apply variables to the xpath and to the text contained in value and deepValue?


toVar

The xpath gets stored in this variable if provided.


count

The count of nodes that matched gets stored in this variable if provided.


done

The patch operation to perform when this one has completed successfully.


error

The patch operation to perform if this one fails or errors.


Errors


Examples

Used In Example:

AddDeep is essentially a more streamlined version of this AddIfMissing implementation:

<Operation Class="NQualityOfLife.XML.AddIfMissing">
    <xpath>Defs/ResearchProjectDef[defName="Hydroponics"]</xpath>
    <toVar>{myXpath}</toVar>
    <value>
        <hiddenPrerequisites/>
    </value>
    <done Class="NQualityOfLife.XML.Add">
        <xpath>{myXpath}/hiddenPrerequisites</xpath>
        <value>
            <li>NQoL_Agriculture_Late</li>
            <li>NMS_TillingN</li>
        </value>
    </done>
</Operation>

<Operation Class="NQualityOfLife.XML.ClearVariable">
    <name>{myXpath}</name>
</Operation>

Converting the above to:

Used In Example:

<Operation Class="NQualityOfLife.XML.AddDeep">
    <xpath>Defs/ResearchProjectDef[defName="Hydroponics"]</xpath>
    <value>
        <hiddenPrerequisites/>
    </value>
    <deepValue>
        <li>NQoL_Agriculture_Late</li>
        <li>NMS_TillingN</li>
    </deepValue>
</Operation>

Used In Example:

<Operation Class="NQualityOfLife.XML.PatchIfExists">
    <xpath>
        Defs/ResearchProjectDef
        [label[contains(text(),"trap") or contains(text(),"IEDs")]]
        [description[contains(text(),"trap")]]
        [not(defName="NQoL_Trapping_Research")]
        [not(prerequisites/li="NQoL_Trapping_Research")]
    </xpath>
    <toVar>{TrapsXpath}</toVar>
    <exists Class="NQualityOfLife.XML.AddDeep">
        <xpath>{TrapsXpath}</xpath>
        <value>
            <hiddenPrerequisites/>
        </value>
        <deepValue>
            <li>NQoL_Trapping_Research</li>
        </deepValue>
    </exists>
</Operation>

<Operation Class="NQualityOfLife.XML.ClearVariable">
    <name>{TrapsXpath}</name>
</Operation>

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