Dictionary to LocalStorage to Dictionary using Json

0 favourites
  • 10 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Can I please have an example or a simple explanation of how to properly turn Dictionary Object into a Json String and place it in to LocalStorage, and how to get the Json String from LocalStorage and load it properly back into the Dictionary Object. I don't mind the use of 2 dictionaries to keep it simple, the concept is the same.

    I can make dictionary object make a Json, but it asks to make a filename and I'm not sure why. From LocalStorage object I can seemingly do it directly without making a filename or even using the "dictionary make json" action. I'm not sure how to load it back into Dictionary or if I'm even loading it into LocalStoage Correctly. I think my problem is naming the location of the Json to load in.

  • I made a .capx.

  • Thanks, it saved me a lot of time.

    I get it now for the most part, I do have it working.

    I was missing ItemValue.

    I didn't know of it until now, It doesn't work without it.

    After a "Check Item Exists", do I have to add "On Item Missing" if I don't want to do anything if its missing?

    What does the action "get item" do if item doesn't exist?

    I think I don't have to add "On Item Missing" and "get item" doesn't do anything if item doesn't exist.

    I just want to confirm, because LocalStorage is asynchronous.

    I don't want to accidentally cause an issue.

  • After a "Check Item Exists", do I have to add "On Item Missing" if I don't want to do anything if its missing?

    Yes.

    What does the action "get item" do if item doesn't exist?

    Nothing.

    On Item Missing might be useful to report back to the user that something misses or to display available savegames.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks again.

    One last question.

    If I have a key named the same as a variable, how do I use key name to set coinciding key to variable with same name?

    Would like to use a "for each" instead of doing 1 by 1.

  • If you want to set a key, simply use the action "Set key" and for the key, you insert your variable.

    If the variable is anything else than a string, make sure to wrap str() around it, since keys can only be strings.

  • Thanks I got it.

  • I made a .capx.

    Hello, this is a old post but can you please re-upload or put in snapshots. THis will help me alot and think others will also find it useful. Thanks.

  • I don't have the capx from this post, but I made a similar example some time ago:

    dropbox.com/s/1cz1k5x3teikbv5/DictionaryLocalStorage.capx

  • Thankyou dop2000.

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