How do I make a game that saves data properly?

0 favourites
  • 7 posts
From the Asset Store
Data+ is the best Data Management solution for Construct 3. It contains 4 Addons (Plugin & Behavior).
  • I mean, i have built a game that counts the number of totalkills that the player has made. I decided to use the web storage (as most of scirra's tutorials suggest) to input a number string as a local value so that when the player starts the game, the web storage updates the variable totalkills to the local value saved before. However, instead of saving the value, the project keeps telling me that the totalkills value is: NaN. i don't know what does this mean and i don't know how to fix it.

    Thanks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • hello, I think you set a string (text) on a number based variable. NaN = Not a Number.

    you should save your variable via "set local value" action. fill the Key with your desired save name, and value with your global variable.

    to load it, use system -> set value -> WebStorage.LocalValue("save name").

    .

    I hope you get it, my english isn't very good.

  • You need to save totalkills to webstorage each time its updated in your game. And call it once on start of layout to set totalkills to webstorage value.

  • That is excatly what i did puntodamar, and i dont think i set a text instead of a number value. And my game set totalkiss value to webstorage value eveytime it is updated in the game thatserafimkid, so i don't know how to work this problem out

  • Make sure you're setting the local key to totalkills (the variable name) and not "totalkills" (a string).

  • And how can i verify if i have set it to the variable and not to a string?

  • It should look like this:

    [attachment=2:34n56jmr][/attachment:34n56jmr]

    And not this:

    [attachment=1:34n56jmr][/attachment:34n56jmr]

    Also in Chrome you can view the value saved in local storage:

    Open the Dev tools (F12). Select resources from the top bar and then click Local Storage on the left. See if you have the correct value stored there.

    [attachment=0:34n56jmr][/attachment:34n56jmr]

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