How do I write multiple dictionaries to a single save file?

0 favourites
  • 5 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • I'm currently using a .json file to save and load my player save data. I want to use a separate dictionary for some other data, but I want to be able to write both dictionaries (and possibly arrays) as a single save file on the player's computer. Is this possible using the single .json file? Or will I have to write multiple .json files and somehow zip them into a new file?

    The "append file" action in NW.js would work to save additional dictionaries, but when I load that data, how would C2 know to separate the data into the correct dictionaries?

  • I would create a new dictionary called 'Master'. For each of the dictionaries you want to save, create a key named for that dictionary, and make the value of that key the dictionary's .json. When you load the Master dictionary, simply set each of your dictionaries to load the JSON from their key using Master.Get(#Dictionaryname)

    I use this technique a lot, it works perfectly

  • That's a very smart way to do it! Thank you!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I assume this is just as easily done with a combination if dictionaries AND arrays inside the master dictionary?

  • Indeed. JSONs nest very nicely to create very complex data structures.

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