Links

Dictionaries Methods

v4.0
Getting and setting values in a Dictionaries object is simple and straightforward. There are also additional helper methods, such as getting a random value from a list of items.

Getting Values

Getting values generally will utilize the Value<T>() method shown below. By default, the method returns the first item in the list -- often it may be the only item. However, you can provide a specific index, or even grab a random value from the list.
In most use cases, the Value<T>() method will be the only method needed at runtime, unless you are actively storing data in the Dictionaries structure.
public T Value<T>(string key, bool random = false, int index = 0)
// Grab the "Flavor Text" of an item object
FlavorText.text = itemObject.dictionaries.Value<string>("Flavor Text");
// Choose a random portrait from a set of available Sprites
// In this example the "class" of a player is stored as an ItemAttribute
var playerPortrait = selectedClass.dictionaries.Value<Sprite>("Portraits", true);

Additional "Get" Methods

// Get a KeyValue object
var foundKeyValue = dictionaries.Key(key);
// Count the items
var numberOfKeyValues = dictionaries.Count(key);
var totalKeyValues = dictionaries.Count(); // No key provided, so counts all KeyValues

Get All Values

Get an Array of all values with Values<T>()
public List<Stat> stats
= dictionaries.Key("Starting Skills").Values<Stat>().ToList();

Adding Values

You can add new information at runtime.
// Add an empty KeyValue. This returns the new KeyValue object.
var newKeyValue = dictionaries.AddNewKeyValue(key);
// Clone an existing KeyValue
var clonedKeyValue = dictionaries.AddNewKeyValue(keyValueToClone);