NQualityOfLife.XML.AddTextVariable - Niilo007/RimWorld-NQoL GitHub Wiki
<Operation Class="NQualityOfLife.XML.AddTextVariable">
<toVar>string</toVar>
<value>string</value>
<xpath>string</xpath>
<settingKey>string</settingKey>
<done Class="PatchOperation"> <!-- Optional -->
</done>
<error Class="PatchOperation"> <!-- Optional -->
</error>
</Operation>
Does not currently support using settings from other mods, but this is a planned feature.
- Variables are global.
- Variable names must begin with '
{
' and end with '}
'
- Gets the value of the provided setting as a string.
- Cannot be used simultaneously with
xpath
orvalue
.
- Gets the value of the provided node as a string.
- Cannot be used simultaneously with
settingKey
orvalue
.
- Sets the variable to the provided string.
- Cannot be used simultaneously with
settingKey
orxpath
.
- The variable name formatted as "{MyVariableName}".
The patch operation to perform when this one has completed successfully.
The patch operation to perform if this one fails or errors.
Trying to add a variable with an incorrectly formatted name results in the following errors:
Config error in Niilo's QoL patch NQualityOfLife.XML.AddTextVariable: Incorrect usage of: 'NQualityOfLife.XML.AddTextVariable' In: 'D:\SteamLibrary\steamapps\common\RimWorld\Mods\Niilo's QoL\1.5\Patches\BugFixes\Fix_Masks.xml'! - 'toVar' is invalid: 'myVariable' - Must start with '{' and end with '}'!
NQoL [E] - Tried to write an invalid variable: 'myVariable' with value: 'Defs/ThingDef[defName="TableButcher"]/description'
NQoL [E] - Incorrect usage of: 'NQualityOfLife.XML.AddTextVariable' In: 'D:\SteamLibrary\steamapps\common\RimWorld\Mods\Niilo's QoL\1.5\Patches\BugFixes\Fix_Masks.xml'! - 'toVar' is invalid: 'myVariable' - Must start with '{' and end with '}'!
NQoL [E] - Tried to write an invalid variable: 'myVariable' with value: 'A heavy table for butchering dead creatures into pieces of raw meat. Rotting or dessicated corpses cannot be butchered.'
The below XML patches result in the following log message:
NQoL - TableButcher description: 'A heavy table for butchering dead creatures into pieces of raw meat. Rotting or dessicated corpses cannot be butchered.'
<Operation Class="NQualityOfLife.XML.AddTextVariable">
<toVar>{myVariable}</toVar>
<xpath>Defs/ThingDef[defName="TableButcher"]/description</xpath>
</Operation>
<Operation Class="NQualityOfLife.XML.Log">
<text>TableButcher description: '{myVariable}'</text>
</Operation>
<Operation Class="NQualityOfLife.XML.ClearVariable">
<name>{myVariable}</name>
</Operation>
- AddTextVariable
- PatchIfExists
- PatchIfEnabledAndExists
- Remove
- PatchIfSetTo
- AddOrReplace
- Log
- ClearVariable
<Operation Class="NQualityOfLife.XML.AddTextVariable">
<value>
Defs/ThingDef
[
thingClass="Building_Storage"
or @ParentName="LWM_DeepStorage"
or @Name="FridgeBase"
or (@ParentName="BuildingBase" and thingClass="Building_Storage")
]
[not(
thingClass="Building_Grave"
or thingClass="Building_Sarcophagus"
or thingClass="Building_GibbetCage"
or weaponTags
or verbs
)]
/building/defaultStorageSettings
</value>
<toVar>{VARstorageBuildingsdefaultStorageSettings}</toVar>
<done Class="NQualityOfLife.XML.PatchIfExists">
<xpath>{VARstorageBuildingsdefaultStorageSettings}</xpath>
<exists Class="PatchOperationSequence">
<operations>
<li Class="NQualityOfLife.XML.PatchIfEnabledAndExists">
<settingKey>NiilosQoL_Settings_No_Default_Filters_Storage</settingKey>
<xpath>{VARstorageBuildingsdefaultStorageSettings}/filter/categories/li</xpath>
<enabledAndExists Class="NQualityOfLife.XML.Remove">
<xpath>{VARstorageBuildingsdefaultStorageSettings}/filter/categories/li</xpath>
</enabledAndExists>
<enabledAndDoesNotExist Class="NQualityOfLife.XML.Log">
<warning>Found no storage filters to patch! this may mean that some other mod already removed default thing filters. (NiilosQoL_Settings_No_Default_Filters_Storage)</warning>
</enabledAndDoesNotExist>
</li>
<li Class="NQualityOfLife.XML.AddTextVariable">
<settingKey>NiilosQoL_Settings_Default_Storage_Priority</settingKey>
<toVar>{NiilosQoL_Settings_Default_Storage_Priority}</toVar>
</li>
<li Class="NQualityOfLife.XML.PatchIfSetTo">
<settingKey>NiilosQoL_Settings_Default_Storage_Priority</settingKey>
<mode>OFF</mode>
<inverse>true</inverse>
<enabled Class="NQualityOfLife.XML.AddOrReplace">
<xpath>{VARstorageBuildingsdefaultStorageSettings}</xpath>
<value>
<priority>{NiilosQoL_Settings_Default_Storage_Priority}</priority>
</value>
</enabled>
<done Class="NQualityOfLife.XML.ClearVariable">
<name>{NiilosQoL_Settings_Default_Storage_Priority}</name>
</done>
</li>
</operations>
</exists>
<doesNotExist Class="NQualityOfLife.XML.Log">
<warning>NQoL [W] - No storage buildings found to patch!</warning>
</doesNotExist>
<done Class="NQualityOfLife.XML.ClearVariable">
<name>{VARstorageBuildingsdefaultStorageSettings}</name>
</done>
</done>
</Operation>
<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>
- AddTextVariable
- AddOrReplace
- Add
- StringConcat
- PatchIfExists
- SetAttribute
- Remove
- AddDeep
- ClearVariable
- Verse.PatchOperationSequence
- Verse.PatchOperationAdd
<li Class="NQualityOfLife.XML.AddTextVariable">
<value>NQoL_Gunpowder_Research</value>
<toVar>{GunPowder}</toVar>
</li>
<li Class="NQualityOfLife.XML.AddTextVariable">
<value>Defs/ResearchProjectDef[not(defName="NQoL_Gunpowder_Research")][defName[contains(text(), "Gunpowder")]]</value>
<toVar>{FindGunPowderXpath}</toVar>
</li>
<li Class="NQualityOfLife.XML.StringConcat">
<value>{FindGunPowderXpath}</value>
<value2>/defName</value2>
<toVar>{FindGunPowderXpath_defName}</toVar>
</li>
<li Class="NQualityOfLife.XML.StringConcat">
<value>{FindGunPowderXpath}</value>
<value2>/tab</value2>
<toVar>{FindGunPowderXpath_tab}</toVar>
</li>
<li Class="NQualityOfLife.XML.PatchIfExists">
<xpath>{FindGunPowderXpath}</xpath>
<exists Class="PatchOperationSequence">
<operations>
<li Class="NQualityOfLife.XML.AddTextVariable">
<xpath>{FindGunPowderXpath_defName}</xpath>
<toVar>{GunPowder}</toVar>
</li>
<li Class="NQualityOfLife.XML.AddOrReplace">
<xpath>{FindGunPowderXpath}</xpath>
<value>
<researchViewX>6.00</researchViewX>
<researchViewY>2.00</researchViewY>
<baseCost>300</baseCost>
<techLevel>Medieval</techLevel>
</value>
</li>
<li Class="NQualityOfLife.XML.SetAttribute">
<xpath>{FindGunPowderXpath}</xpath>
<attribute>ParentName</attribute>
<value>NQoL_Progression_Project</value>
</li>
<li Class="NQualityOfLife.XML.Remove">
<xpath>{FindGunPowderXpath_tab}</xpath>
<success>Always</success>
</li>
<li Class="NQualityOfLife.XML.AddDeep">
<xpath>{FindGunPowderXpath}</xpath>
<value>
<prerequisites/>
</value>
<deepValue>
<li>NQoL_Fire_Research</li>
</deepValue>
</li>
</operations>
</exists>
<doesNotExist Class="PatchOperationAdd">
<xpath>Defs</xpath>
<value>
<ResearchProjectDef ParentName="NQoL_Progression_Project">
<defName>NQoL_Gunpowder_Research</defName>
<label>gunpowder</label>
<description>Learn to make gunpowder and use it to improve existing weapons. Or maybe even some new ones.\n\nThe powder leaves behind a lot of residue, perhaps the formula could be improved to fix this issue.</description>
<baseCost>300</baseCost>
<techLevel>Medieval</techLevel>
<prerequisites>
<li>NQoL_Fire_Research</li>
</prerequisites>
<tags>
<li>ClassicStart</li>
</tags>
<researchViewX>6.00</researchViewX>
<researchViewY>2.00</researchViewY>
</ResearchProjectDef>
</value>
</doesNotExist>
</li>
<li Class="NQualityOfLife.XML.ClearVariable">
<name>{FindGunPowderXpath_defName}</name>
</li>
<li Class="NQualityOfLife.XML.ClearVariable">
<name>{FindGunPowderXpath_tab}</name>
</li>
<li Class="NQualityOfLife.XML.ClearVariable">
<name>{FindGunPowderXpath}</name>
</li>
<li Class="NQualityOfLife.XML.Add">
<xpath>Defs</xpath>
<value>
<ResearchProjectDef ParentName="NQoL_Progression_Project">
<defName>NQoL_HandCannon_Research</defName>
<label>hand cannons</label>
<description>Learn to use gunpowder to propel projectiles.</description>
<baseCost>200</baseCost>
<techLevel>Medieval</techLevel>
<prerequisites>
<li>{GunPowder}</li>
<li>NQoL_Javelin_Research</li>
<li>Smithing</li>
</prerequisites>
<tags>
<li>ClassicStart</li>
</tags>
<researchViewX>3.00</researchViewX>
<researchViewY>1.20</researchViewY>
</ResearchProjectDef>
</value>
</li>
- AddTextVariable
- AddOrReplace
- Add
- PatchIfExists
- SetAttribute
- Remove
- AddDeep
- ClearVariable
- Verse.PatchOperationSequence
<li Class="NQualityOfLife.XML.AddTextVariable">
<value>NQoL_Gunpowder_Research</value>
<toVar>{GunPowder}</toVar>
</li>
<li Class="NQualityOfLife.XML.PatchIfExists">
<xpath>Defs/ResearchProjectDef[not(defName="{GunPowder}")][defName[contains(text(), "Gunpowder")]]</xpath>
<toVar>{FindGunPowderXpath}</toVar>
<exists Class="PatchOperationSequence">
<operations>
<li Class="NQualityOfLife.XML.AddTextVariable">
<xpath>{FindGunPowderXpath}/defName</xpath>
<toVar>{GunPowder}</toVar>
</li>
<li Class="NQualityOfLife.XML.AddOrReplace">
<xpath>{FindGunPowderXpath}</xpath>
<value>
<researchViewX>6.00</researchViewX>
<researchViewY>2.00</researchViewY>
<baseCost>300</baseCost>
<techLevel>Medieval</techLevel>
</value>
</li>
<li Class="NQualityOfLife.XML.SetAttribute">
<xpath>{FindGunPowderXpath}</xpath>
<attribute>ParentName</attribute>
<value>NQoL_Progression_Project</value>
</li>
<li Class="NQualityOfLife.XML.Remove">
<xpath>{FindGunPowderXpath}/tab</xpath>
<success>Always</success>
</li>
<li Class="NQualityOfLife.XML.AddDeep">
<xpath>{FindGunPowderXpath}</xpath>
<value>
<prerequisites/>
</value>
<deepValue>
<li>NQoL_Fire_Research</li>
</deepValue>
</li>
</operations>
</exists>
<doesNotExist Class="NQualityOfLife.XML.Add">
<xpath>Defs</xpath>
<value>
<ResearchProjectDef ParentName="NQoL_Progression_Project">
<defName>{GunPowder}</defName>
<label>gunpowder</label>
<description>Learn to make gunpowder and use it to improve existing weapons. Or maybe even some new ones.\n\nThe powder leaves behind a lot of residue, perhaps the formula could be improved to fix this issue.</description>
<baseCost>300</baseCost>
<techLevel>Medieval</techLevel>
<prerequisites>
<li>NQoL_Fire_Research</li>
</prerequisites>
<tags>
<li>ClassicStart</li>
</tags>
<researchViewX>6.00</researchViewX>
<researchViewY>2.00</researchViewY>
</ResearchProjectDef>
</value>
</doesNotExist>
</li>
<li Class="NQualityOfLife.XML.ClearVariable">
<name>{FindGunPowderXpath}</name>
</li>
<li Class="NQualityOfLife.XML.Add">
<xpath>Defs</xpath>
<value>
<ResearchProjectDef ParentName="NQoL_Progression_Project">
<defName>NQoL_HandCannon_Research</defName>
<label>hand cannons</label>
<description>Learn to use gunpowder to propel projectiles.</description>
<baseCost>200</baseCost>
<techLevel>Medieval</techLevel>
<prerequisites>
<li>{GunPowder}</li>
<li>NQoL_Javelin_Research</li>
<li>Smithing</li>
</prerequisites>
<tags>
<li>ClassicStart</li>
</tags>
<researchViewX>3.00</researchViewX>
<researchViewY>1.20</researchViewY>
</ResearchProjectDef>
</value>
</li>