How do I.. Trouble with Local Key

Get help using Construct 2

Post » Mon Jul 20, 2015 6:22 am

Morning all guys!

Sorry to bother, but has been 3 days I'm dealing with a problem I cannot figure out.

Here what I'm doing: a slot-machine with a splash-intro. The slot-machine is ok.. There is a variable (money) connected to a local webstorage key (moneysave) who saves everything in the cookies. The problem is in the splash.

There's a text box, where I show the string "WebStorage.LocalValue("moneysave") so it shows the amount of chips I've.

THE PROBLEM IS ON THE CREATION OF A BUTTON WHO'S ADDING money to that value.
I tried several ways to do it, but some are adding strange values, other not working at all. Obviously the new value has to be saved in the same local webstorage.

Do you have any suggestion?
I'm sure it's simple, but I cannot figure out.

Cannot sleep. Lol.. Thank guys! :cry:
B
5
S
1
Posts: 10
Reputation: 397

Post » Mon Jul 20, 2015 6:30 am

What do you mean by adding strange values? Maybe your event is firing multiple times per click?
B
10
S
2
Posts: 33
Reputation: 710

Post » Mon Jul 20, 2015 10:02 am

Thanks for the answer! Unlucky no. To be sure of it, i've set the button to disappear after 1 single tap.

For example, I want to add the value 2000 to 1736. I've, as result 4000, sometimes 6000, etc etc, but never the correct value. It's driving me crazy!
B
5
S
1
Posts: 10
Reputation: 397

Post » Mon Jul 20, 2015 10:08 am

Please share your capx or at least a screenshot of your event sheet, without it we can only guess..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jul 20, 2015 10:30 am

Ya, sorry!
So, first image is the working part - Just to show you SETTING_START_CREDITS, the value of my money, and the session key "Chips" where I save everything. Here everything is working and done.


Image

Here there is the part with troubles. (see the rectangles). Quiet simple.. want to add value "2000" to the amount of money, then save it automatically. But the result is just 2000, without the Chips I alread got!



Image
B
5
S
1
Posts: 10
Reputation: 397

Post » Mon Jul 20, 2015 11:50 am

I'm not sure but are you setting the global variable SETTING_START_CREDITS to the webstorage value anywhere?
If not, SETTING_START_CREDITS - 0 at start of layout, so adding 2000 will make it 2000 which you then save to webstorage..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jul 20, 2015 11:59 am

Also I see you are using session key and local key for the webstorage

The textobject is set to local value, while you are saving to session value..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jul 20, 2015 7:16 pm

Ya, what the hell.
Seen it and correct!

Now it's working properly!
Thanks a lot guys, much appreciated!
B
5
S
1
Posts: 10
Reputation: 397

Post » Tue Jul 21, 2015 9:35 am

Moreover In your event 12 the "Add to action", you are actually adding the string value of 2000, not the the numeric value.
Don't use quotes when dealing with numbers.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
296
S
119
G
96
Posts: 7,328
Reputation: 71,288


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 3 guests