> For the complete documentation index, see [llms.txt](https://infinitypbr.gitbook.io/magic-pig-games/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://infinitypbr.gitbook.io/magic-pig-games/game-modules-4/v4-migration-tips/dictionaries.md).

# 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.
