Check for Update/enlarge existing array

Easy Save 2 has been replaced by Easy Save 3, so is no longer supported.
Locked
nowISnow
Posts: 2
Joined: Tue Aug 08, 2017 8:42 am

Check for Update/enlarge existing array

Post by nowISnow »

I am using Unity 2017.4.40f1 with EZ 2 and Playmaker 1.8.5

I just updated my app from V1 to V2

In V1 I use an array to save which items where purchased or free of charge.

In V2 I added more items, so I have a larger array.

So far I checked, if the save-file exists and if so, I load the data. Works fine. But now in V2 it can only load the "old" data of course and I am kind of stuck how to update the array in the save file without losing the save data and adding my new data.

As for now, when I load the array from the V1 saved file, it will override ("delete") my new items, as they are all set to "0".

Is there a (playmaker) function, to check if an array entry exsists in the save file? Or any other ideas, how to solve this problem?

And is there a way to manually shorten the array in EZ2/Unity using the file editor for testing purpose?
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Check for Update/enlarge existing array

Post by Joel »

Hi there,

I'm not sure I understand what you mean, would you be able to give me a summary of the code you're using and how this differs between versions?

If I understand correctly, you would need to load the old array, and then convert it to a new array.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
nowISnow
Posts: 2
Joined: Tue Aug 08, 2017 8:42 am

Re: Check for Update/enlarge existing array

Post by nowISnow »

The main problem was, that when I was loading the array list data from the save file, it shortened the array, which had more entries by definition in the new version.

Version 1: array list with 7 items.

Version 2: array list with 10 items.

When I loaded the save file, the array list in V2 was shortened to 7 items. So instead of loading the data for the first 7 items and keeping the new three, it replaces the array list. Right?

I build a solution where I check if item 8 is available after loading and if not, I add the 3 new items manually.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Check for Update/enlarge existing array

Post by Joel »

So just to make sure I'm understanding correctly:
  • In version one your code expects to load an array of 7 items
  • In version two your code expects to load an array of 10 items
In this case you would need to check the length of the array after loading and manage it accordingly.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Locked