# Dictionaries

## Accessing values

Values are now accessed with a different method. Note, the v3.x method will work, but will be deprecated soon, as it is only left to handle auto migration of data.

```
// Example v3.x code

public virtual void OnPointerEnter(PointerEventData eventData) 
            => flavorText.UpdateText(stat.dictionaries.Key("Flavor Text").ValueString());

// Example v4 code

public virtual void OnPointerEnter(PointerEventData eventData) 
            => flavorText.UpdateText(stat.dictionaries.Value<string>("Flavor Text"));
```

In the above example, rather than calling `dictionaries.Key("Flavor Text").ValueString()` we call `dictionaries.Value<string>("Flavor Text")`.

We specify the type, and provide the `Key` in the signature. There are still options for returning a random value or a specific index. As shown above, it will return the first value of the list, or the default value if the Key is not found.

{% hint style="info" %}
You can also access the value via the `KeyValue` object itself, but if the Key is not found, a null reference will occur.

`flavorText.UpdateText(stat.dictionaries.Key("Flavor Text").Value<string>());`
{% endhint %}

### Migration to V4 Button

Objects which have Dictionaries will also have a "Migrate to v4" button. Pressing this will move existing Dictionaries data to the new structure.

<figure><img src="/files/SRcAkZdzuZwvzLx62vhd" alt=""><figcaption></figcaption></figure>

The previous version had one entry for every data type, so you may need to remove the empty values for types that you are not actually using, by pressing the red "X" button.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://infinitypbr.gitbook.io/magic-pig-games/game-modules-4/v4-migration-tips/dictionaries.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
