Multiple Variables in under same Key in a Dictionary?

0 favourites
  • 5 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I think saw a tutorial not long ago where it was mentioned that you could store multiple values under the same "key". Is it true or did I just imagine it?

    I kind of need two return values from a single key and I hoped I could use the dictionary instead creating an array.


  • The dictionary data is only a single object, but you can store any string, so if you save concatenated data, you can parse it back out. If you use AsJSON on a dictionary or array, then you can store that, and Load it back out again, effectively giving you a dictionary of dictionaries, or, a dictionary of arrays.

    Other than that, you can't really store "two" values in one key.

  • Once again, thanks for clearing things out for me BlackHornet!

  • If you only need 2 values I guess the simplest way is to store them as "Value1, Value2" in a single key and then use tokenat to get them. For example tokenat(Dictionary.Get("ThatParticularKey"), 0, ", ") will get you the first value in the key. Change the 0 to 1 and you get the second *value. The 0 is the index and the ", " is the separator between values.

    EDIT: meant to say *value, not key

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I just found out of that and it works perfectly for my needs.

    I'm making a crafting system, and in a combination of array and dictionary it works like a charm and very scalable.

    But thanks! :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)