Page 1 of 1

too many overloads on ES.Load()?

Posted: Thu Jun 25, 2020 4:04 am
by Snoopy
I followed the getting started and want to do something like:
ES3.Load<string>("playerName", "Default Name")

but I noticed if I call that first without saving then as expected the save file isn't found but it throws an exception instead of giving me the default value.

Debugging why, it turns out its not going to this overload like I expected:
public static T Load<T>(string key, T defaultValue)

but instead its going to:
public static T Load<T>(string key, string filePath)

So to fix that I did:
ES3.Load<string>("playerName", "Default Name", ES3Settings.defaultSettings);

hoping that it would go to:
public static T Load<T>(string key, T defaultValue, ES3Settings settings)

but instead it went to:
public static T Load<T>(string key, string filePath, T defaultValue)

So to fix that I did:
ES3.Load<string>("playerName", "ES3/ES3Defaults", "Default Name", ES3Settings.defaultSettings);

and that finally worked cause it went to:
public static T Load<T>(string key, string filePath, T defaultValue, ES3Settings settings)

but geez. There's no exposed way to get to
private const string defaultSettingsPath = "ES3/ES3Defaults";
so I have to mirror that.

Seems like there's a few too many overloads named Load() when I just want to do something basic like this.

Is there a better way?

Thanks!

Re: too many overloads on ES.Load()?

Posted: Thu Jun 25, 2020 7:21 am
by Joel
Hi there,

Unfortunately it's necessary to have a lot of overloads as any combination of these is necessary depending on the project, but agreed this does make it difficult when saving strings. To make life easier in this case I'll add an ES3.LoadString method. If you private message me your invoice number I can send this over.

Just to clarify, the following will always return the default settings:

Code: Select all

new ES3Settings();
All the best,
Joel