Is it just me or am i not able to save an Instance Variable?

Discussion and feedback on Construct 2

Post » Fri Aug 08, 2014 9:36 pm

Hi everyone,

It seems like im not able to load up or save my instance variable that ive chosen to represent an Unlocked/Locked state.
All of my Globals load up and save just fine.

Right now when the player touches the confirm button inside the store it saves using this code.
Webstorage-->Set Local Key"GunUnlock" To TurretGun_BttnFam.UnlockedGun

When i load the game from the first layout i use this code.
Set UnlockedGun To int(WebStorage.LocalValue("GunUnlock"))

Im not understanding why it will not save my chosen variable,am i doing something wrong?
Last edited by RookieDev on Fri Aug 08, 2014 10:14 pm, edited 1 time in total.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Fri Aug 08, 2014 9:42 pm

You are saving UnlockedGun to one webstorage key ("PowerupUnlock") and trying to load it from different key ("GunUnlock")
Or do I miss something in your explanation?
ImageImageImageImage
B
158
S
67
G
43
Posts: 2,603
Reputation: 36,003

Post » Fri Aug 08, 2014 10:19 pm

@shinkan that was my mistake,I fixed it inside the post,Its not that way inside my capX and never was.I just wrote to fast in this post.
I am still having this issue.It will not save the state of the instance variable.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Fri Aug 08, 2014 10:39 pm

hard to say without looking at your file. It works fine on my end.
ImageImageImageImage
B
158
S
67
G
43
Posts: 2,603
Reputation: 36,003

Post » Fri Aug 08, 2014 10:40 pm

What does the webstorage say about the saved value? (Look inside the browser itself)
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
54
S
22
G
18
Posts: 2,123
Reputation: 17,150

Post » Fri Aug 08, 2014 10:51 pm

@Aphrodite What do you mean? could you clarify that statement?

@shinkan do you mind if i PM it to you? I have it set up the same way as i posted. Im just about finished with my project and its too far gone to post out in the public.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Fri Aug 08, 2014 10:56 pm

sure
ImageImageImageImage
B
158
S
67
G
43
Posts: 2,603
Reputation: 36,003

Post » Fri Aug 08, 2014 10:58 pm

@shinkan its coming your way right now,Thank you for checking this out.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Sat Aug 09, 2014 2:40 am

Don't use WebStorage.Set. Instead use WebStorage.Add
Same with dictionary. And here is why,

1. Until you Add a value to Web/Dict there is no variable to set with. So Setting won't work.
2. Add will always add a variable.
3. Add will overwrite a variable that already exists. So your never actually increasing the number of vars stored.

So unless there is better memory performance with using Set. Just use Add all the time.

I had the same problem over a year ago. Then I read the manual and was informed this piece of information.
B
92
S
18
G
9
Posts: 2,455
Reputation: 15,113

Post » Sat Aug 09, 2014 5:09 pm

Never mind. I'm being a doorknob. WebStorage s not the same. I guess I overlooked the value since I only use WebStorage to save bulk data in Dictionaries.ToJson.

RookieDev are you maybe clearing your WebStorage for development testing?
B
92
S
18
G
9
Posts: 2,455
Reputation: 15,113

Next

Return to Construct 2 General

Who is online

Users browsing this forum: dop2000 and 1 guest