How do I keep my data between layouts

0 favourites
  • 7 posts
  • 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?

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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?

  • 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.

  • 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?

  • 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.

  • 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)