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

Class

Related:


C#

internal static class Vars
{

}

XML


Usage

The Vars class handles the XML patch variables.

Variable names must begin with '{' and end with '}'.

Variables must be cleared before the main menu screen / when your patches are done.
Best practice is to clear a variable as soon as it is no longer needed, such as after the patch that uses it or at the end of the file if the variable is used a lot in that file.

Variables can also be used across multiple patch files. In that case its best to clear it after all other patches in a separate file that is know to run last.


Errors


Examples

Used In Example:

<Operation Class="NQualityOfLife.XML.AddTextVariable">
    <toVar>{myXpath}</toVar>
    <value>
        Defs/ThingDef[not(defName[contains(text(), "Passive")])]
        [not(designatorDropdown) or defName[contains(text(), "_Over")]]
        [not(stuffCategories)]
        [label[contains(text(),"cooler")] or defName[contains(text(),"Cooler")]]
        [not(description[contains(text(),"water")])]
        [
            thingClass="Building_Cooler"
            or @ParentName[contains(string(), "Cooler")]
            or thingClass[contains(text(),"Cooler")]
            or
            (
                description[contains(text(),"cooling")]
                and
                (
                    description[contains(text(),"Cool")]
                    or description[contains(text(),"cool")]
                )
            )
        ]
    </value>
</Operation>

<Operation Class="NQualityOfLife.XML.StringConcat">
    <value>{myXpath}</value>
    <value2>[not(defName="Cooler")]</value2>
    <toVar>{probe}</toVar>
</Operation>

<Operation Class="NQualityOfLife.XML.PatchIfExists">
    <xpath>Defs/ThingDef[defName="Cooler"][not(designatorDropdown)][not(stuffCategories)]</xpath>
    <probe>{probe}</probe>
    <bothExist Class="NQualityOfLife.XML.AddOrReplace">
        <xpath>{myXpath}</xpath>
        <value>
            <designatorDropdown>PatchPack_Coolers</designatorDropdown>
        </value>
    </bothExist>
</Operation>

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

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

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