Proper way to load a byte array into ES3?

Discussion and help for Easy Save 3
Post Reply
David_Nightcap
Posts: 17
Joined: Sun Apr 12, 2020 1:18 pm

Proper way to load a byte array into ES3?

Post by David_Nightcap »

So my ES3 saving/loading code has been working fine but long story short, I'm running into some bugs months after I thought it was working fine.
I found I was calling ES3.SaveRaw() in the my load data function that is reading a byte array (due to platform) from disk.
It's been a long time since I looked at this and don't know why I would have put a ES3.SaveRaw() in here.

Here's the suspicious code:

Code: Select all

bool successful = false;
byte[] fileAsByteArray = NXSave.Load(ref successful);

if(successful)
{
     string strData = System.Text.Encoding.ASCII.GetString(fileAsByteArray);
     Debug.Log(strData);

     ES3.SaveRaw(fileAsByteArray, settings);    

     if (ES3.KeyExists("YarnVariables"))
          LoadYarnVariablesFromString(ES3.Load<string>("YarnVariables"));     
}
Is this the proper way to load a byte array into ES3 to use?

Doesn't this also write the byte array to disk?


The problem I'm running into is that ES3.KeyExists() returns false here even though it's clearly in the byte array when I print it out (no typos, etc.), so LoadYarnVariablesFromString() never gets called. Why would it be false unless it's not actually loaded into ES3? So what's the right way to load the entire array into ES3 then?

ES3.LoadRawBytes() exists, but loads the file into memory. I already have the byte array from a platform specific loading method. How do you get that into ES3?

Thanks.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Proper way to load a byte array into ES3?

Post by Joel »

Hi there,

You appear to be supplying a Settings object to the Save method, but not the Load or KeyExists method, so this could be a possible source of the issue.
Doesn't this also write the byte array to disk?
That is correct, unless you use caching (https://docs.moodkie.com/easy-save-3/es ... rformance/)
I already have the byte array from a platform specific loading method. How do you get that into ES3?
You would use SaveRaw to save the data to the cache.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
David_Nightcap
Posts: 17
Joined: Sun Apr 12, 2020 1:18 pm

Re: Proper way to load a byte array into ES3?

Post by David_Nightcap »

AHA! There it is. Yep, that was it.
Looks like I missed a few ES3 calls when I switched from the older version where I wasn't passing settings to every call.
Thanks!
Post Reply