How do I Load saved data?

0 favourites
  • 5 posts
From the Asset Store
DATA+ (Addon Pack)
$11.25 USD
50% off
Data+ is the best Data Management solution for Construct 3. It contains 4 Addons (Plugin & Behavior).
  • I may be missing something here, but I am getting my game to save each levels score into an array, and then save that data as Local Web storage. Now this works when I test it on my browser and it even works when I install my app. But as soon as I quit my app and re open it all the data is not loaded, its like it was using session web storage rather than Local. Has anyone else had this problem or know where I may be going wrong? Thank you in advance.

  • Hard to tell with the little screenshot here.

    But apparently, you are simply not loading the saved data when you start your application.

    You set a local key named "Level" but on start of layout try to load a local key named "XBest" (where X is a number).

    As far as I can tell from the screenshot, no key "XBest" exists.

    Also I'm not sure starting the key name by a number is the wisest thing to do anyway.

    Make sure to save "Level"X"Best" keys at the end of each levels, and then you should be able to load data from those keys afterwards.

    If you are still having issues, consider posting your whole capx as it may help finding the issue easier.

  • Hi Kyatric,

    Appreciate the reply. The game is currently in Beta and I am not allowed to post the full .capx file am afraid.

    The most confusing thing is that the code for the high scores works. My game remembers the high scores for each level, so clearly the information is being stored and recalled correctly. But as soon as I exit the app and come back they have reset.

    Essentially I have a global variable called Level that starts on 1 and as a level is completed +1 is added to it. Once the level is won, the score global varible is tested to see if it is grater than the value stored in the array ( Array_Best_LevelScore ) of the same number ( Level ) if it is the new score is then saved into that slot and displayed. This is then saved as a local key level*global varible*&("Best"). If it is not grater than the array the text simply displays the current array slot value. As noted this all works when the game is running, but its like my array is not being saved......

    As I have been rambling I think I see what you are getting at.... I am saving the array numbers as Local values, but I am not re loading those (levelnumber)Best local values back into the array when the game starts!! What an idiot.

    Ha will give that a try thank you very much!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Your screenshot is a bit of a mess.

    What I do is take the game out and make a small demo - get it to work then put that demo into game.

    From what I see, I understand that when level > webstorage you want to set the score... but I find this isn't the best way to do it. It is essentially everytick. Game runs through eventsheet evertick and if Level>webstorage it stores it.

    How do you store score to variable level? I would create a function to save to storage and put that immediately after you update score.

    This does 3 things.

    1) It only updates - writes to webstorage when player score changes(he could be running around for half an hour without picking up a coin - lol), and

    2)removes the every tick check.

    3) and you can feel all fuzzy and warm inside knowing that his score and webstorage are being updated together (which is what level>webstorage is) but this way is better. Nothing worse than a player loosing his latest score - Grrrrrr - lol

  • Hey DUTOIT,

    Some good tips there I will try to implement them, thank you very much for the help!

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