Can someone help me with webstorage?

Get help using Construct 2

Post » Sat Nov 17, 2012 2:09 am

I've been trying to fully understand how webstorage works (it's my only option, since a save function doesn't even exist in C2 yet) and I'm having a very tough time of getting webstorage in action to work, even when I understand the basics and the gist of it. I stopped working on one of my projects for three months because I couldn't get past this.

If someone could make a better/in-depth tutorial (I've tried all the tutorial/page/etc resources, anyway) or a demo on how to save values like HP, weapons, progress (such as if boss a has been defeated or if key item b has been obtained), that would be great.
Zelda Gamekit (my project)

Example capxs I have made:
Zelda-Style Inventory
Zelda Hearts System

The unwritten "How do I" capx etiquette! Nearly always provide a capx of the problem you have, and try to isolate the problem and/or no capx above 10 MB. :)
B
38
S
19
G
26
Posts: 438
Reputation: 16,581

Post » Sat Nov 17, 2012 3:01 am

Well ... Did you check in the tutorial section
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

Post » Sat Nov 17, 2012 3:15 am

I said that in my post.
Zelda Gamekit (my project)

Example capxs I have made:
Zelda-Style Inventory
Zelda Hearts System

The unwritten "How do I" capx etiquette! Nearly always provide a capx of the problem you have, and try to isolate the problem and/or no capx above 10 MB. :)
B
38
S
19
G
26
Posts: 438
Reputation: 16,581

Post » Sat Nov 17, 2012 2:07 pm

The WebStorage object is actually very simple. Have you read the manual entry on WebStorage which briefly describes how to use it? It's also very similar to the Dictionary object (link has another brief description of how it works).
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Sun Nov 18, 2012 8:33 pm

Actually, with the project I had going; I almost got WebStorage working but was encountering problems with it remembering data post-load.
Zelda Gamekit (my project)

Example capxs I have made:
Zelda-Style Inventory
Zelda Hearts System

The unwritten "How do I" capx etiquette! Nearly always provide a capx of the problem you have, and try to isolate the problem and/or no capx above 10 MB. :)
B
38
S
19
G
26
Posts: 438
Reputation: 16,581

Post » Sun Nov 18, 2012 11:55 pm

You'd want to use a combination of WebStorage and Array. Basically, all the in-game stats can be easily kept track of via an array object, then when it comes time to save you can save it all as a string in WebStorage. Here's a really good tutorial on it.

http://www.scirra.com/forum/saving-and-loading-an-array-to-webstorage-capx_topic50970.html

That tutorial is as basic as you're going to get with what you're asking for, and it's the best tutorial for it, too.

One thing to keep in mind: it saves everything as a long string, so when it gets loaded back into the game data array all your integers become strings again, so any time you call a variable from the array and expect to use it as a number, remember to use the int(x) or float(x) System expressions to stay on the safe side.
B
57
S
20
G
7
Posts: 305
Reputation: 8,779

Post » Wed Nov 21, 2012 10:05 pm

That's actually what I'm doing.
Zelda Gamekit (my project)

Example capxs I have made:
Zelda-Style Inventory
Zelda Hearts System

The unwritten "How do I" capx etiquette! Nearly always provide a capx of the problem you have, and try to isolate the problem and/or no capx above 10 MB. :)
B
38
S
19
G
26
Posts: 438
Reputation: 16,581

Post » Sun Nov 25, 2012 5:23 am

Any help please?
Zelda Gamekit (my project)

Example capxs I have made:
Zelda-Style Inventory
Zelda Hearts System

The unwritten "How do I" capx etiquette! Nearly always provide a capx of the problem you have, and try to isolate the problem and/or no capx above 10 MB. :)
B
38
S
19
G
26
Posts: 438
Reputation: 16,581

Post » Sun Nov 25, 2012 8:04 am

Check out the second post here:
http://www.scirra.com/forum/www.scirra.com/forum/copy-an-entire-array_topic53153.html

It really helped me a lot! It just saves the array instantly, and you can load it again just as fast. I have it in my project now keeping track of levels, items, missions, custom statistics, the works.
B
27
S
8
G
5
Posts: 429
Reputation: 6,902


Return to How do I....?

Who is online

Users browsing this forum: Khamsou and 21 guests