Save a variable so it keeps its value even on exit

0 favourites
  • 11 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hello!

    I want to buy Construct 2, but I first want to make sure that it is equipped with this feature.

    Basically, lets say that my game has a 'Highscore' global variable and a 'Level' global variable. I want to save both of those variables so, even if the user quits my application and restarts their device (this will probably be either a NodeWebkit desktop application or an Android app), my variables will be remembered and reloaded when they reopen the application.

    Is this possible, and if so, how? Please explain in a newb-friendly way.

    Thanks!

    OrangeFlash81

  • OrangeFlash81

    Firstly, welcome to the forum!

    Construct2 can save both number variables and text strings (eg, names on a scoreboard) using a plugin called 'web storage'. You can find out more in this Manual entry here: https://www.scirra.com/manual/120/webstorage

    It's ridiculously easy to use (I've just started using it in my current project and was surprised to discover I only needed to add the object and click a few buttons) and saves data via cookies. scirra have recently added an even better saving feature which allows you to add a proper save game system to projects, though I've yet to experiment with it.

  • Dave Hailwood, what about completely offline saving? does webstorage or the new save game system work for that?

  • Dave Hailwood, what about completely offline saving? does webstorage or the new save game system work for that?

    Yeah, that was what I had in mind. Thanks for your suggestion though Dave. I might end up using that. Would that still work on Android, though?

    Thanks!

  • damjancd

    OrangeFlash81

    Webstorage is the browser storage, if the cache isn't deleted, it should stay (even on node-Webkit)

    And for the Node Webkit plugin, you can save a file with data in a folder on the user computer, and also load a file, so, it works offline

    (the node-webkit plugin is still in beta though, so you may take that in consideration)

    Hope that helps

  • Aphrodite Thanks for the reply, I'm particularly interested in iOS completely offline data saves. So webstorage doesn't work for me since I need a reliable method to save a game. I'm aiming for a Appstore release a week or two after they release ios 7 (hopefully with webGL enabled) :]

  • WebStorage works offline, works on all platforms, and is permanent. It is *not* saved in the browser cache; it's permanent and immune to the user clearing their cache. (I don't know why everyone assumes it saves to the cache!)

    There's also good support for full-state savegames and the node-webkit plugin allows writing to disk when a desktop application.

  • WebStorage works offline, works on all platforms, and is permanent. It is *not* saved in the browser cache; it's permanent and immune to the user clearing their cache. (I don't know why everyone assumes it saves to the cache!)

    There's also good support for scirra.com/tutorials/526/how-to-make-savegames and the node-webkit plugin allows writing to disk when a desktop application.

    Thanks! Problem, though; I can't find the WebStorage object anywhere. I am on Construct 2 Free Edition Release 119. I am looking to buy Standard.

    P.S. With Standard, can I sell games that I create? Or is that only for Business releases?

  • you should first update your version to 126 or the 130 Beta

    Webstorage is an Object, just add it to your project

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • > WebStorage works offline, works on all platforms, and is permanent. It is *not* saved in the browser cache; it's permanent and immune to the user clearing their cache. (I don't know why everyone assumes it saves to the cache!)

    >

    > There's also good support for scirra.com/tutorials/526/how-to-make-savegames and the node-webkit plugin allows writing to disk when a desktop application.

    Thanks! Problem, though; I can't find the WebStorage object anywhere. I am on Construct 2 Free Edition Release 119. I am looking to buy Standard.

    P.S. With Standard, can I sell games that I create? Or is that only for Business releases?

    Right-click on your layout and add object, then select web storage. Now it will be available throughout your project. And yes, you can sell games with a standard license. If you exceed a certain threshold of revenue, you need to upgrade to business.

  • Thanks everybody!

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