> For the complete documentation index, see [llms.txt](https://scenegroup.gitbook.io/cavalry/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://scenegroup.gitbook.io/cavalry/nodes/utilities/context-index.md).

# Context Index

The **Context Index** Utility acts as an input that only exists during the computation of the nodes. Nodes that have an input connection from other nodes may choose to provide context to these input nodes to produce different results. Duplicator is one such node, and it provides an index context to all of its inputs.

{% hint style="info" %}
Check out the [Index](/cavalry/getting-started/key-concepts/context.md) page for some background reading on this concept.
{% endhint %}

This node allows us to use the context information to achieve more specific and intricate results.

To visualise the 'index context', follow these steps:

1. Create a [Type Shape](/cavalry/nodes/shapes/text-shape.md).
2. Add a [String Generator](/cavalry/nodes/utilities/string-generator.md).
3. Set **Generator** to **Value**.
4. Set **Precision** and **Padding** to **0**.
5. Add the Text Generator to a [Duplicator](/cavalry/nodes/shapes/duplicator.md).
6. On the **Grid Distribution** set the **Count** to **X = 1**, **Y = 10**.
7. Create a **Context Index** Utility.
8. Connect ***contextIndex.id > textGenerator.number***.

![](https://1676825895-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LT2-S1m8aSPAI_Gg3Q1%2F-Lg7sj22eJu5W1FSqDPv%2F-Lg81iUBmiKtNrb1DaqM%2FcontextNumbers1.png?alt=media\&token=57f192c6-19d9-4d70-8d95-6c8c918dc388)

Nothing too unexpected there. So let's take this a bit further.

#### Context Depth

When a node provides context, it gets added to a chain of contexts. If we have a Duplicator within a Duplicator, then the chain will contain two index contexts. What the **Context Index** allows you to do is choose the 'depth' of those contexts provided to other nodes.

Example (continued from the previous example):

1. Add the Duplicator to a second Duplicator.
2. Set Duplicator2's **Grid Distribution** to **Count X = 5, Count Y = 1**.\
   **Result:** The index value travels through the second Duplicator.

![An index of 0-49 (50 total) passed to all duplicates. ](https://1676825895-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LT2-S1m8aSPAI_Gg3Q1%2F-Lg7sj22eJu5W1FSqDPv%2F-Lg81lUQXq37fgaTZaOI%2FcontextNumbers2.png?alt=media\&token=436e842f-d3a8-4742-a4ce-5b7abae704a6)

Duplicator1 automatically accumulates the index from Duplicator2, which is why we get numbers ranging from 0 to 49 even though we have selected a **Depth** value of **1**. We can change this:

1. In the [Attribute Editor](/cavalry/user-interface/menus/window-menu/attribute-editor.md), right-click on Duplicator1's header and uncheck **Advanced** -> **Use Incoming Index.**\
   **Result:** The numbers now represent the index from **Duplicator1**.

![A Depth of 1 outputs the index provided by Duplicator1](https://1676825895-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LT2-S1m8aSPAI_Gg3Q1%2F-Lg9hIT71AEKJDrK2yYM%2F-Lg9iyNkhu4Aw8pvclVl%2FcontextNumber3.png?alt=media\&token=b223b87a-3a1e-46c2-a1ba-c1204c9d593e)

1. Set **Depth** on the **Content Index** to **2**.

![A Depth of 2 outputs the index provided by Duplicator2](https://1676825895-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LT2-S1m8aSPAI_Gg3Q1%2F-Lg9hIT71AEKJDrK2yYM%2F-Lg9jPvXqjo8l5vNLAdn%2FcontextNumber4.png?alt=media\&token=f24363cb-fa76-4c52-a5d9-66ffb177adb3)

1. The numbers now represent the index coming from **Duplicator2**.

#### Bonus

Combining Context Index Atoms with a [Jsmath](/cavalry/nodes/utilities/js-math.md) Atom can create some interesting results.

1. Create another **Context Index** Atom.
2. Ensure **Depth** is set to **1** (default).
3. Create a [Jsmath](/cavalry/nodes/utilities/js-math.md) Atom.
4. Connect ***contextIndex2.id > jsmath.array.0*** (aka 0: Number - the first input).
5. Set the **Expression** to be: `0.5 + n0 * n0 * 0.01`
6. Connect **jsmath.id** to both **duplicator1.shapeScale.x** and **duplicator1.shapeScale.y**.

![Using the index of Duplicator1 to scale the shapes generated by Duplicator2.](https://1676825895-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LT2-S1m8aSPAI_Gg3Q1%2F-Lg9hIT71AEKJDrK2yYM%2F-Lg9kr9xLVqMz35VTTMv%2FcontextNumber5.png?alt=media\&token=67cf8ed2-edd7-43ab-9362-54c1cebf0c53)

.
