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

ClearVariable

Related:


XML

<Operation Class="NQualityOfLife.XML.ClearVariable">
    <name>string</name>
    <names>
        <li>string</li>
    </names>
    <debugAllowNoClear>bool</debugAllowNoClear> <!-- false -->
    <done Class="PatchOperation"> <!-- Optional -->

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

    </error>
</Operation>

Usage

Used to clear a variable when it is no longer needed.


Errors

Trying to clear a variable that does not exist will result in the following error:

NQoL [E] - Tried to clear variable: '{myVariable}' but no such variable exists!


Examples

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** ⚠️