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

SetAttribute

Related:

XML

<Operation Class="NQualityOfLife.XML.SetAttribute">
    <xpath>string</xpath>
    <attribute>string</attribute>
    <value>string</value>
    <done Class="PatchOperation"> <!-- Optional -->

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

    </error>
</Operation>

Usage

Sets the <attribute> of <xpath> to <value>.

Errors

Examples

Used In Example:

<Operation Class="NQualityOfLife.XML.GetOrAddAttribute">
    <xpath>Defs/ThingDef[defName="SimpleResearchBench"]</xpath>
    <attribute>Name</attribute>
    <value>SimpleResearchBench</value>
    <toVar>{newOrExistingAttribute}</toVar>
    <done Class="NQualityOfLife.XML.SetAttribute">
        <xpath>Defs/ThingDef[defName="NQoL_ResearchSpot"]</xpath>
        <attribute>ParentName</attribute>
        <value>{newOrExistingAttribute}</value>
    </done>
</Operation>

Used In Example:

<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>
⚠️ **GitHub.com Fallback** ⚠️