Sync Dictionary with WebStorage

Get help using Construct 2

Post » Tue Aug 06, 2013 12:59 am

I have a global Dictionary in my project that I want to use to track statistics like current money count, number of HP upgrades, etc. I also want to save these values to WebStorage.

I want to:
1) Load values from Local Storage when the global Dictionary is created
2) Save values from Dictionary to Local Storage when they are altered (or at the end of a level)

How can I do this? Is a global Dictionary the best way to go?
B
9
S
1
Posts: 98
Reputation: 853

Post » Tue Aug 06, 2013 9:43 pm

Can u give me an example capx? Also have you considered using an array and saving/loading as json to Local Storage?

I'm not sure how that works with dictionary
B
9
S
2
G
2
Posts: 59
Reputation: 1,024

Post » Wed Aug 07, 2013 1:05 am

B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Wed Aug 07, 2013 1:18 am

@ramones

Just what I was thinking
B
9
S
2
G
2
Posts: 59
Reputation: 1,024

Post » Thu Aug 08, 2013 8:33 pm

Wow, that was amazingly simple! Thanks!

EDIT: Bonus question: how do you save objects to a JSON file (or multiple, but preferably one) and load them from said file to transfer save files between computers? Or better yet save them to Dropbox?

EDIT 2: Never mind the Dropbox; I think the plugin for it should be simple enough when I want it. How about basic save&load to/from file, though?MoscowModder2013-08-08 22:52:31
B
9
S
1
Posts: 98
Reputation: 853


Return to How do I....?

Who is online

Users browsing this forum: dop2000, evillair, lordsas, Matei511, tarek2 and 64 guests