Most efficient storage/retrieval

0 favourites
  • 4 posts
  • This is driving me crazy. I have a "sophisticated" storage system that seems tidy in theory but in reality introduces a lot of bugs.

    This is all of the player's data, scattered around several objects:

    * Player: Health, ammo, etc; resets every level

    * PlayerStats (Global Dictionary): Equipped items, number of upgrades, current money; saved to WebStorage as JSON every level/change

    * BoughtItems (Global Dictionaty): Which items have been bought in the store (only one per category can be equipped; that's saved in PlayerStats); saved to WebStorage after every purchase

    * LevelScores (Global Array): Highest score on each level; saved after every level

    * LevelStats (Global Array): Current in-level stats (kills, damage, etc) used to calculate your score. NOT saved to Webstorage.

    Is this a good way to manage a large assortment of data? Or is there a better way to keep track of all these numbers?

  • I eventually saved everything to dictionary.

    I have a json file that I ajax into dictionary for static data and save dynamic in game data stored into a second dictionary and

    and save that dictionary to webstorage.

    It still isn't perfect, so will watch what more knowledgeable folks say. But, it works better than tons of data all over the place.

  • You might want to check out Rex Hash plugin:

    It allows you to create hierarchical ("multidimensional") dictionaries. This way, you could get a better structure of your stored data, creating objects like this:

    world1.title = "Cool World" = "Evil bunny" = 100 = "Nasty kitten" = 150

    world2.title = "Warm World"

    ...and so on.

    All with just one object.

    Maybe not the best example, but I think you get the point.

    I really hope they include it as an official plugin someday, as arrays and single-leveled dictionaries are way too limited for complex data management, and Javascript already includes more powerful alternatives.

    Although Rex plugin is great, it lacks some features like sorting on keys or values, so you might need to complement it with normal arrays. My own plan is to modify the plugin, or create my own, to support sorting once I get there, as I feel that arrays are too limited for most of my needs.

    Unless you're updating huge amounts of data at the same time, performance shouldn't be an issue.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey, awesome! This should also make multiple save files much easier in the future. Thanks!

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