NQualityOfLife.XML.AddOrReplace - Niilo007/RimWorld-NQoL GitHub Wiki
<Operation Class="NQualityOfLife.XML.AddOrReplace">
<xpath>string</xpath>
<success>Always</success> <!-- Optional -->
<toVar>string</toVar> <!-- Optional -->
<value>
</value>
<done Class="PatchOperation"> <!-- Optional -->
</done>
<error Class="PatchOperation"> <!-- Optional -->
</error>
</Operation>
- If
<toVar>
is provided, the given<xpath>
is saved to it.- Variable names must begin and end with '
{
' & '}
'
- Variable names must begin and end with '
Ending the xpath with the node you are trying to add will result in the following error:
NQoL [E] - Incorrect usage of: 'NQualityOfLife.XML.AddOrReplace' In: '∅'! - 'xpath' (Defs/ThingDef[defName="Steel"]/stuffProps/statFactors/Flammability) should not end with the node we are adding or replacing (Flammability)!
<Operation Class="NQualityOfLife.XML.AddOrReplace">
<success>Always</success>
<xpath>Defs/ResearchProjectDef[defName="MF_BasicFurniture"]</xpath>
<value>
<tab>NQoL_Progression</tab>
<researchViewX>2.00</researchViewX>
<researchViewY>5.60</researchViewY>
</value>
</Operation>
- AddOrReplace
- Add
- AddTextVariable
- 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>