Events doesn't work properly with array if it was filled with values from local storage.

0 favourites
  • 5 posts
From the Asset Store
"Easy Local Notifications" enhances games with customizable local notifications.
  • I have a problem accessing array after loading from local storage.

    I have an array with (81, 1, 1) size.

    I have different events using this array without any problems. Like events in this example. Let’s call it “example_1”.

    Then I decided to make save game option. For this I write and read (save and load) this array’s values in local storage.

    I’ve checked array after using this save/load functions and it’s filled absolutely correctly.

    However after using load function events in “example_1” stopped working.

    Looks like this event says array doesn’t contain value. I’ve checked many times, same array with same values – this event (and many similar) works before saving/loading and then doesn’t work after.

    I’ve changed this events so they now looks like this:

    I think I solved this problem only partly. My project contains lot of code and uses arrays a lot. So I fear somewhere somehow I won't fix this and problems will happen. And this bugs are difficult to find and identify.

    I've tried different Construct 2 versions and problem happens in all of them. Did any of you have this bug? Could you explain nature of it so I could fix it? Or maybe you know the way how to deal with it.

  • the way you are trying to load the values from local storage is not going to work.

    Also, you should not save each value in the array separately - you should save the whole array

  • the way you are trying to load the values from local storage is not going to work.

    But why? Let's image I have lots of variables in local storage. How to load them correct?

    Also, you should not save each value in the array separately - you should save the whole array

    Thank you, I'll try.

  • your "Load Game" function doesn't actually load any values from local storage. You are using the Compare Value event, but that will not have a value until after a "Get Item" or "Check Item Exists" action is performed.

    You can save values separately in local storage if you want, but you will end up with a lot of Save actions and then Get actions, and I have heard people complain that that makes their game very slow.

    You can load lots of variables into one array or dictionary and then save those all in one operation. It is ok to save several items separately, but I would try to keep that number as low as possible.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • your "Load Game" function doesn't actually load any values from local storage. You are using the Compare Value event, but that will not have a value until after a "Get Item" or "Check Item Exists" action is performed.

    You can save values separately in local storage if you want, but you will end up with a lot of Save actions and then Get actions, and I have heard people complain that that makes their game very slow.

    You can load lots of variables into one array or dictionary and then save those all in one operation. It is ok to save several items separately, but I would try to keep that number as low as possible.

    Thank you for your answer. I'll look into it.

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