NQualityOfLife.XML.Iterate - Niilo007/RimWorld-NQoL GitHub Wiki
<Operation Class="NQualityOfLife.XML.Iterate">
<xpath>string</xpath>
<toVar>string</toVar> <!-- Optional -->
<count>string</count> <!-- Optional -->
<applyVariables>bool</applyVariables> <!-- true -->
<item Class="PatchOperation">
</item>
<done Class="PatchOperation"> <!-- Optional -->
</done>
<error Class="PatchOperation"> <!-- Optional -->
</error>
</Operation>
The Iterator substitutes {i}
with xpath[i]
where i
is the index of the item.
So:
<Operation Class="NQualityOfLife.XML.Iterate">
<xpath>Defs/HeadTypeDef</xpath>
<item Class="NQualityOfLife.XML.Log">
<xpath>{i}/defName</xpath>
<error Class="NQualityOfLife.XML.Log">
<xpath>{i}</xpath>
</error>
</item>
</Operation>
Would look like this:
<Operation Class="NQualityOfLife.XML.Iterate">
<xpath>Defs/HeadTypeDef</xpath>
<item Class="NQualityOfLife.XML.Log">
<xpath>Defs/HeadTypeDef[i]/defName</xpath>
<error Class="NQualityOfLife.XML.Log">
<xpath>Defs/HeadTypeDef[i]</xpath>
</error>
</item>
</Operation>
Used to select the nodes to iterate.
Supports variables.
Apply variables to the xpath
and to the text contained in value
?
The xpath
gets stored in this variable if provided.
- 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 '
The count
of iterated items gets stored in this variable if provided.
The patch operation that gets applied to each matching item.
The patch operation to perform when this one has completed successfully.
The patch operation to perform if this one fails or errors.
- Iterate
- Verse.PatchOperationSequence
- AddTextVariable
- Log
- ClearVariable
<Operation Class="NQualityOfLife.XML.Iterate">
<xpath>Defs/HeadTypeDef</xpath>
<item Class="PatchOperationSequence">
<operations>
<li Class="NQualityOfLife.XML.AddTextVariable">
<toVar>{myVar}</toVar>
<xpath>{i}/defName</xpath>
<error Class="NQualityOfLife.XML.AddTextVariable">
<toVar>{myVar}</toVar>
<value>null</value>
</error>
</li>
<li Class="NQualityOfLife.XML.Log">
<message>{i} -> {myVar}</message>
<done Class="NQualityOfLife.XML.ClearVariable">
<name>{myVar}</name>
</done>
</li>
</operations>
</item>
</Operation>