Most efficient storage/retrieval

Get help using Construct 2

Post » Sun Aug 25, 2013 5:43 am

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?MoscowModder2013-08-25 06:03:58
B
10
S
2
Posts: 104
Reputation: 1,140

Post » Sun Aug 25, 2013 9:52 am

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 think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,718

Post » Sun Aug 25, 2013 8:37 pm

You might want to check out Rex Hash plugin:
http://www.scirra.com/forum/plugin-hash-table_topic47637.html

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"
world1.enemies.0.name = "Evil bunny"
world1.enemies.0.health = 100
world1.enemies.1.name = "Nasty kitten"
world1.enemies.1.health = 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.
B
18
S
3
Posts: 57
Reputation: 1,081

Post » Sun Aug 25, 2013 11:00 pm

Hey, awesome! This should also make multiple save files much easier in the future. Thanks!
B
10
S
2
Posts: 104
Reputation: 1,140


Return to How do I....?

Who is online

Users browsing this forum: Lordshiva1948 and 7 guests