Save a variable

Get help using Construct 2

Post » Tue Feb 21, 2017 6:32 am

hi guys, i know i have a silly question, im new to construct but i have a bit of programming knowledge, ok so i have menu layout and event sheet and game layout and event sheet, when i press the button the menu button from the game i set value "chooser=2" ,then in menu when i restart, chooser reverts back to its initial value of 1. basically im allowing the user to start a new level but in essence just restarting the same layout while needing to save some variables that unlocks buttons.

i have tried the level saving capx but for the life of me, my variables aren't saving.
B
6
S
1
Posts: 17
Reputation: 386

Post » Tue Feb 21, 2017 6:52 am

B
79
S
31
G
7
Posts: 148
Reputation: 9,179

Post » Tue Feb 21, 2017 2:10 pm

What's "restart" means to you? F5 in the browser? because if that's the answer, you need to go with the previous advice ;)
BUT don't use a LocalStorage key for every varible. Save them in a Dictionary and then pass it to only one key on the LocalStorage. Here's a example that I've just prepared for another guy about how to use it: https://www.dropbox.com/s/ndhr3i5qw9300 ... .capx?dl=0
Lead developer at Octeto Studios
Visit our portfolio at: http://www.octetostudios.com/ :)
Facebook || Twitter || Youtube
B
37
S
7
G
5
Posts: 217
Reputation: 5,613

Post » Tue Feb 21, 2017 2:43 pm

hi guys, thanx alot, no i haven't tried local storage as yet, will give it a go, sorry i'm still using r227, capx refuses to open unless i have r239 or higher. will give feedback
B
6
S
1
Posts: 17
Reputation: 386

Post » Tue Feb 21, 2017 2:49 pm

You always can download r239 only to open up my example ;)
Good luck!
Lead developer at Octeto Studios
Visit our portfolio at: http://www.octetostudios.com/ :)
Facebook || Twitter || Youtube
B
37
S
7
G
5
Posts: 217
Reputation: 5,613

Post » Tue Feb 21, 2017 3:21 pm

will do but currently i'm trying to get webstorage to work, i am saving the value to key but how do i increment key by 1 each time a button is clicked?
B
6
S
1
Posts: 17
Reputation: 386

Post » Tue Feb 21, 2017 3:25 pm

In my example there is a sum using the keys indeed hahaha
Lead developer at Octeto Studios
Visit our portfolio at: http://www.octetostudios.com/ :)
Facebook || Twitter || Youtube
B
37
S
7
G
5
Posts: 217
Reputation: 5,613

Post » Tue Feb 21, 2017 3:30 pm

lol ok let me download r239
B
6
S
1
Posts: 17
Reputation: 386

Post » Tue Feb 21, 2017 3:52 pm

GamerGon wrote:In my example there is a sum using the keys indeed hahaha

ok so i have had a look but im not getting anywhere quickly. your example displays all scores as 0
B
6
S
1
Posts: 17
Reputation: 386

Post » Tue Feb 21, 2017 4:12 pm

thanx alot guys, got it working with global variable and webstorage...
B
6
S
1
Posts: 17
Reputation: 386

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests