How do I keep my data between layouts

Get help using Construct 2

Post » Mon Sep 15, 2014 12:15 am

I am having an issue with keeping my information when loading a new layout. If I have my character reach level 6 and kill 3 monsters they display in a bestiary in layer 1, everything works. But Once I switch layouts everything has a value of 0. Im trying to make a RPG with different zones the player can visit

Is there a simple way to keep all my information consistent between layouts without spamming global variables?
B
15
S
4
Posts: 31
Reputation: 1,267

Post » Mon Sep 15, 2014 12:35 am

You could try saving them using webstorage( as they change, or just before you exit the particular layout) and loading the values on start of layout. If saved Locally rather than Session, the values would carry over even if if you shut the game down.
B
10
S
3
Posts: 15
Reputation: 1,191

Post » Mon Sep 15, 2014 2:32 pm

How can I load specific values using web storage? Like my hero array has hero name level and hp values. How would I set and load this array on a new layout?
B
15
S
4
Posts: 31
Reputation: 1,267

Post » Mon Sep 15, 2014 2:49 pm

@smoke84 You could also trigger auto-saving to a save slot when you first enter the layout, which would save all your data and not require any complex events. Depends on how large your game is and if the auto-save would take too long because of it, of course.
Founder of Jadelight Studio, Developer of Libertas Aedifex, regular C2 Help contributor and fan of ambient music and Star Wars.
B
12
S
4
Posts: 255
Reputation: 2,008

Post » Mon Sep 15, 2014 2:52 pm

I tried saving to a slot at the end of level 1 but when I start level 2 all values are blank (name level hp etc)

How can I save at end of level 1 and load values from that save in level 2?
B
15
S
4
Posts: 31
Reputation: 1,267

Post » Mon Sep 15, 2014 2:55 pm

Hmm, strange. I've yet to use the Save function but the documentation states it saves all variables (global and local), as well as instance variables. So I'm unsure as to why you've lost all yours, I'm afraid.
Founder of Jadelight Studio, Developer of Libertas Aedifex, regular C2 Help contributor and fan of ambient music and Star Wars.
B
12
S
4
Posts: 255
Reputation: 2,008

Post » Mon Sep 15, 2014 3:26 pm

WIthout many global variables the best option is to use WebStorage, before loading a new layout save all usefull information, once the new layout is loaded, load the variables from webstorage and update your hud.
With webStorage you can save stuff just like a dictionary:

"key" value

"heroName" "myName"
"heroLvl" 10
"heroHp" 100
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 24 guests