What does deleting an array do?

0 favourites
  • 4 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • I've come across an issue where I save "items" the player finds in an array by pushing it back on the x axis and adding the "itemname" (I do it this way in order to sort the array and call a list of each item you have).

    However, if you do multiple saves, or loads, or new games, (which clear the array, and then load it via localstorage) clearing the array resets it, but when you go to make a list of the necessary items, it stays at whatever size it was before. I thought maybe I could delete the array, but that just removed it from the game entirely and made it so you could no longer use it. I've noticed there's no manual representation of what destroying an array does (OR dictionary, for that matter)

    It's quite clear to stay away from arrays for anything that plays with size, so I'll have to figure out another way to go about it.

  • Couldn't you just reset the size of the array when you save or load? Seems like a pretty easy fix.

    Doesn't it work to use the set size action and just set it back to. 1, 1, 1 when you load or save?

  • ome6a1717

    I don't entirely understand what you are saying but

    When you load an array from local storage or whatever,

    the size is set by the json file you are loading in.

    It doesn't matter what the size of the array was before this.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • tunepunk - ah I think you might be right. I just realized that I'm not supposed to set it 1,1,1 (because that's not the actual default value I'm using).

    NetOne - that's actually really good to know - thank you!

    So now that you've all helped me solved that, I'm legitimately curious; what is the purpose of destroying an array or dictionary?

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