How do I save a double to a specific value in an array using ES3?

Discussion and help for Easy Save 3
Post Reply
kaarlo
Posts: 1
Joined: Sun Mar 05, 2023 10:36 am

How do I save a double to a specific value in an array using ES3?

Post by kaarlo »

So, I have this problem where I have a double array saved to ES3. I would like to save a double to a specific place in the array, like so:

Code: Select all

        for (int i = 0; i < levelPbs.Length; i++)
        {
            if (levelPbs[i] < ES3.Load<double[]>("levelPbs")[i])
            {
                ES3.Save<double[]>("levelPbs", levelPbs); //save levelpbs[i] to ES3 levelpbs[i]
            }
        }
and I would like to save levelPbs (position i) to the already saved levelPbs array, at position i

Is this possible, or will I have to just make a lot of doubles?
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: How do I save a double to a specific value in an array using ES3?

Post by Joel »

Hi there,

You would need to load the array, insert the value into the correct position, and then resave the array. In your example you're already loading array anyway so the cost of doing this would be neglible.

You could save each item out to separate keys but this would be very inefficient for anything other than small arrays, so it's not recommended.

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