Storing lots of data

Get help using Construct 2

Post » Sun Dec 16, 2012 9:53 am

I need to store quite a lot of data to detail star systems in my game (about 100 or 200 systems, with maybe 10 planets each). Off the top of my head, I want to store them as sprite objects (with no graphic obviously) with about 20 or 30 variables for each, but this sounds very wrong. An array would do the same trick I suppose, but it still sounds wrong to have 2000 arrays. Would this cause problems with memory or performance and if so, how would I be better off storing this amount of data?
B
25
S
5
G
3
Posts: 446
Reputation: 5,633

Post » Sun Dec 16, 2012 4:57 pm

Use ARRAY. This is what it's built for as you get a nice Download and Load feature using JSON storage. So it's a great way to use webstorage or AJAX.

I can see you need a lot of data and I'm not sure if 3 levels deep is enough. I would suggest maybe an alternative storage model than 1 node = 1 piece of data. Check out the manual for Expression on strings and tokenate function. Tokenate splits string data by character.
String = "name|x|y|gravity|wealth|minerals|foo|...."
example = "Zebes|100|200|0.5|poor|low|hostile|...."

so then you array can be
Array[systems][planets]


Or you can use Spritebank(plugin) which I think will store all your sprite data and reload them when you want.


edit:
By default browsers easily allow up to 5mb of data. Past that browsers prompt users for the website to use more data. However even at 200 systems * 10 planets. You will still have enough room.jayderyu2012-12-16 17:07:35
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Sun Dec 16, 2012 5:58 pm

Thanks, I'm not sure what I was thinking, clearly an array is the answer. It's funny, when I used to use arrays for everything (in the 'old' days) and then OOP appeared, I really hated not using arrays. Now I really hate arrays! I don't like having to remember which element contains which value, but in this case it's definitely the way forward. I like your idea of tokenising string data to simplify the storage, I might use that :)
B
25
S
5
G
3
Posts: 446
Reputation: 5,633


Return to How do I....?

Who is online

Users browsing this forum: alextro, Aserak2012, ManuelPerez and 20 guests