Page 1 of 1

Es3.Load<string> exception

Posted: Mon Jan 15, 2024 10:18 pm
by RogueProgrammer
I have no issues using the ES3.Load for a number of different data types however, when I try and use it to load in a string that was saved, I get an exception. It appears it is trying to use the Key as the filename for some reason.

If I check to see if the key exists and then load it, it succeeds. However if I call Load<string> with a default string, it gets an exception and when I trace into the ode it is trying to open a save file with the name of the strings key. So if I call the string "test" it would try and open a save file named test.

Here is an example showing how it works and how it fails:

Code: Select all

            string SupportGUID = "";
            
            // this works
            if (ES3.KeyExists("SupportGUID"))
            {
                SupportGUID = ES3.Load<string>("SupportGUID");
            }

            // This fails with an exception because it tries to open a save file named "SupportGUID"
            SupportGUID = ES3.Load<string>("SupportGUID", "");
From the documentation, it seems I am calling the Load<string> correctly. So what am I doing wrong?

Re: Es3.Load<string> exception

Posted: Tue Jan 16, 2024 8:36 am
by Joel
Hi there,

The second parameter to the ES3.Load method in that case would be the filename, not the default value. If you want to specify the defaultValue parameter you should use a named parameter. I.e.

string str = ES3.Load<string>(key, defaultValue: " ");

All the best,
Joel

Re: Es3.Load<string> exception

Posted: Tue Jan 16, 2024 11:42 pm
by RogueProgrammer
Thank you! I must have missed that in the doc.