How do I recall all the keys from Local Storage?

0 favourites
  • 6 posts
From the Asset Store
Random Maze Generator with Door & Key System - tutorial capx
  • Construct 3/Mobile App

    I set the LocalStorage key to: "keyName" & sprite.squareInst & sprite.monthInst & sprite.yearInst

    And it actually worked!

    If one key is created each day, how do I call all the keys on start of layout?

    If it works there would be around 1500 keys after 4 years.

    Would that be too many on a single mobile device?

    Thank you.

  • If one key is created each day, how do I call all the keys on start of layout?

    + System: On start of layout
    -> LocalStorage: Get all key names
    
    + LocalStorage: On all key names loaded
    ----+ System: Repeat LocalStorage.KeyCount times
    -----> Text: Append LocalStorage.KeyAt(LoopIndex)
    

    Would that be too many on a single mobile device?

    If it's an app, it should probably be fine. Unless you are storing huge images in each key. You can run a stress test - save 2000 keys and see if there are any problems.

  • dop2000,

    Thank you for the reply.

    I got stuck.

    It is images. It's a photo app, but only a small one and it only has to really work for a month. It's to teach my autistic daughter to understand and tell what she did yesterday.

    I got the first part, right up to -----> Text: Append LocalStorage.KeyAt(LoopIndex)

    I thought I could do the same with a sprite, but I don't see an append on the sprite options. It came right up with text, but not sure how to do it with a sprite.

    Is the code different or am I just missing it?

    Thanks again.

    + LocalStorage: On all key names loaded

    ----+ System: Repeat LocalStorage.KeyCount times

    -----> Text: Append LocalStorage.KeyAt(LoopIndex)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • LocalStorage.KeyAt(LoopIndex) returns only the name of the key. So if there are 100 keys in local storage, this loop will print all 100 names (but not their content)

    + LocalStorage: On all key names loaded
    ----+ System: Repeat LocalStorage.KeyCount times
    -----> Text: Append LocalStorage.KeyAt(LoopIndex)
    

    If you need to display 100 images from these keys, you will have to retrieve each key into BinaryData object and then into a sprite. And you need enough empty frames in the sprite for all 100 images.

    Here is a demo:

    dropbox.com/scl/fi/ip3l882ooiiwt69kpq5v2/LS_SaveLoadMultipleImages.c3p

    Click Draw+Save a few times. Then click Load.

  • dop2000,

    Thank you.

    Dropbox tells me I can't access the file, and tells me to request access.

    So I did that, but I'll work on what you said until then.

  • dop2000,

    OH!! Yes, that makes sense.

    Thank you so much!

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