Page 1 of 1

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

Posted: Sun Mar 05, 2023 10:42 am
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?

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

Posted: Sun Mar 05, 2023 1:31 pm
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