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

PatchIfEnabledAndExists

Related:


XML

<Operation Class="NQualityOfLife.XML.PatchIfEnabledAndExists">
    <settingKey>string</settingKey>
    <xpath>string</xpath>
    <debugAlwaysEnabled>bool</debugAlwaysEnabled> <!-- false -->
    <toVar>string</toVar> <!-- Optional -->
    <enabledAndExists Class="PatchOperation"/>
    <disabledAndExists Class="PatchOperation"/>
    <enabledAndDoesNotExist Class="PatchOperation"/>
    <disabledAndDoesNotExist Class="PatchOperation"/>
    <doesNotExist Class="PatchOperation"/>
    <disabled Class="PatchOperation"/>
    <done Class="PatchOperation"> <!-- Optional -->

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

    </error>
</Operation>

Usage

Does not currently support using settings from other mods, but this is a planned feature.

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

Errors

Setting debugAlwaysEnabled to true results in the following errors:

Config error in Niilo's QoL patch NQualityOfLife.XML.PatchIfEnabledAndExists: debugAlwaysEnabled - Key: 'spark comp test' -> 'NQualityOfLife.XML.PatchIfEnabledAndExists' In: 'D:\SteamLibrary\steamapps\common\RimWorld\Mods\Niilo's QoL\1.5\Patches\WIP\WIP_SparkComp.xml'! - 'debugAlwaysEnabled' is 'True'!

NQoL [E] - debugAlwaysEnabled - Key: 'spark comp test' -> 'NQualityOfLife.XML.PatchIfEnabledAndExists' In: 'D:\SteamLibrary\steamapps\common\RimWorld\Mods\Niilo's QoL\1.5\Patches\WIP\WIP_SparkComp.xml'! - 'debugAlwaysEnabled' is 'True'!

Having an empty setting key (<settingKey></settingKey>) results in the following errors:

Config error in Niilo's QoL patch NQualityOfLife.XML.PatchIfEnabledAndExists: Incorrect usage of: 'NQualityOfLife.XML.PatchIfEnabledAndExists' In: 'D:\SteamLibrary\steamapps\common\RimWorld\Mods\Niilo's QoL\1.5\Patches\BugFixes\Fix_HediffGiver_RandomDrugEffect.xml'! - 'settingKey' is '​ε'!

NQoL [E] - Incorrect usage of: 'NQualityOfLife.XML.PatchIfEnabledAndExists' In: 'D:\SteamLibrary\steamapps\common\RimWorld\Mods\Niilo's QoL\1.5\Patches\BugFixes\Fix_HediffGiver_RandomDrugEffect.xml'! - 'settingKey' is '​ε'!

A missing settingKey results in the following errors:

Config error in Niilo's QoL patch NQualityOfLife.XML.PatchIfEnabledAndExists: Incorrect usage of: 'NQualityOfLife.XML.PatchIfEnabledAndExists' In: 'D:\SteamLibrary\steamapps\common\RimWorld\Mods\Niilo's QoL\1.5\Patches\BugFixes\Fix_HediffGiver_RandomDrugEffect.xml'! - 'settingKey' is '∅'!

NQoL [E] - Incorrect usage of: 'NQualityOfLife.XML.PatchIfEnabledAndExists' In: 'D:\SteamLibrary\steamapps\common\RimWorld\Mods\Niilo's QoL\1.5\Patches\BugFixes\Fix_HediffGiver_RandomDrugEffect.xml'! - 'settingKey' is '∅'!


Examples

Used In Example:

<Operation Class="NQualityOfLife.XML.PatchIfEnabledAndExists">
    <settingKey>NiilosQoL_Settings_Warn_About_Mods</settingKey>
    <xpath>Defs</xpath>
    <enabledAndExists Class="PatchOperationSequence">
        <operations>
            <li Class="NQualityOfLife.XML.WarnIfAnyLoaded">
                <useName>true</useName>
                <useId>true</useId>
                <warning>NQoL Notice - ###Weight price## | Niilo's QoL - Have overlapping functionality! - Sort items by 'value / mass'</warning>
                <mods>
                    <li>deivisis.weightprice</li>
                    <li>Weight price</li>
                    <li>Weight price (Continued)</li>
                </mods>
            </li>
        </operations>
    </enabledAndExists>
</Operation>

Used In Example:

<Operation Class="NQualityOfLife.XML.PatchIfEnabledAndExists">
    <settingKey>NiilosQoL_Settings_Disable_SunLampTimer</settingKey>
    <xpath>Defs/ThingDef[thingClass="Building_SunLamp" or defName[contains(text(), "SunLamp")]]/comps/li[@Class="CompProperties_Schedule"]</xpath>
    <toVar>{targetXpathSunLampTimer}</toVar>
    <enabledAndExists Class="NQualityOfLife.XML.Remove">
        <xpath>{targetXpathSunLampTimer}</xpath>
    </enabledAndExists>
    <doesNotExist Class="NQualityOfLife.XML.Log">
        <warning>NQoL [W] - (No Action Needed) - Failed to remove sun lamp off period! It was not found or was already removed by some other mod. (NiilosQoL_Settings_Disable_SunLampTimer)</warning>
    </doesNotExist>
</Operation>

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

Used In Example:

<Operation Class="NQualityOfLife.XML.PatchIfEnabledAndExists">
    <settingKey>spark comp test</settingKey>
    <debugAlwaysEnabled>true</debugAlwaysEnabled>
    <xpath>Defs/ThingDef[comps[li[@Class="CompProperties_FireOverlay"]]]</xpath>
    <toVar>{ThingsToPatchWithSparks}</toVar>
    <enabledAndExists Class="NQualityOfLife.XML.AddDeep">
        <xpath>{ThingsToPatchWithSparks}</xpath>
        <value><comps/></value>
        <deepValue>
            <li Class="NQualityOfLife.Comps.FireSpreader_Properties"/>
        </deepValue>
    </enabledAndExists>
    <enabledAndDoesNotExist Class="NQualityOfLife.XML.Log">
        <warning>Failed to find any fire spreading things!</warning>
    </enabledAndDoesNotExist>
</Operation>

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

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