How do I - Webstorage Arrays Multiple Levels

Get help using Construct 2

Post » Tue Sep 23, 2014 4:53 pm

Im really stuck here.

I have been following some tutorials trying to get my arrays into webstorage but it is only half working.
What happens is... The webstorage is saving only some of my data. (Im not positive its saving data still or if its loading an old key, but that green checkmark makes me think it still is.)
In the two pictures below it saves the fact that i completed level one yet wont unlock level two even when the current level variable shows that it should be going up.
Image
For some reason there is no change.
Image

And this is how i have my webstorage and array events set up (as the tutorial said, so i must be missing a step.)

The top picture is on the game events page
Image


The bottom picture is on my level select page
Image

Image
Whats strange is that it saves my progress and shows what levels i completed and how many stars i achieved when reloading the browser, but it wont let me progress.


Im sure i explained this really horribly. Maybe someone could help me start fresh with saving my array to webstorage. None of the tutorials cover multiple levels. Maybe send me a pm and i can show you my capx. So stuck right now :/
Last edited by Crawnic on Wed Sep 24, 2014 11:48 am, edited 1 time in total.
B
15
S
2
Posts: 69
Reputation: 1,270

Post » Tue Sep 23, 2014 4:54 pm

Oh and heres the rest of the events that cover the level select.

Image
B
15
S
2
Posts: 69
Reputation: 1,270

Post » Tue Sep 23, 2014 5:06 pm

Line52:
Set value at currentlevel to max(2+star, int(levels.at(currentlevel)))

When you store in webstorage values will be converted into string, so you have to convert them back to number using int() to load it into number variables.
B
28
S
8
G
4
Posts: 553
Reputation: 4,914

Post » Tue Sep 23, 2014 5:21 pm

Hmm i tried changing that and i can now move on to the next level but its still not doing the whole webstorage part.

Just to clarify was this what you meant?
Image
B
15
S
2
Posts: 69
Reputation: 1,270

Post » Tue Sep 23, 2014 5:36 pm

Yes, and not just that, basically everything that uses your levels array.
B
28
S
8
G
4
Posts: 553
Reputation: 4,914

Post » Tue Sep 23, 2014 11:34 pm

Hmm :/

Still trying to figure this out i showed you everything that references the arrays in the pictures. Do you have any other suggestions? Or would you look at my capx?

How would i go about adding Int() to the other parts that reference the arrays?

Im still a little confused.
B
15
S
2
Posts: 69
Reputation: 1,270

Post » Wed Sep 24, 2014 9:33 am

You have to unlock the next level in the array when you complete a level. After you 'Add 1 to currentLevel', you should set the array value at currentLevel to 1.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,630

Post » Thu Oct 02, 2014 8:42 pm

@Crawnic
Did you find the answer?
I have same problem here!
B
7
S
1
Posts: 53
Reputation: 545

Post » Fri Oct 03, 2014 12:29 am

I actually did not find the answer. I did get it fixed though.

Unfortunately i had to use a working capx as a base file and pretty much work off of that by transferring my files into the capx.
https://www.scirra.com/tutorials/1160/p ... l-selector

Thank you for the capx @duckfaceninja !
B
15
S
2
Posts: 69
Reputation: 1,270


Return to How do I....?

Who is online

Users browsing this forum: mikehive, plinkie and 10 guests