ES2.Exists

Easy Save 2 has been replaced by Easy Save 3, so is no longer supported.
Locked
drwayyyne
Posts: 5
Joined: Fri Mar 27, 2015 1:01 pm

ES2.Exists

Post by drwayyyne »

Hey Joel,

I want to give the player the opportunity to have multiple save files and name them as he/she sees fit. I now want to check if my save folder has any file of that type rather than a specific file, to see if it makes sense to give the option of loading.

I was now doing this:

Code: Select all

if (ES2.Exists("*.dat")) print("true");
else print("false");
However, my code returns false even though I have according data in the according folder. Is there a way to check for any file instead of a specific file or a folder (both are no options in my case)?


Thanks in advance,
David
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: ES2.Exists

Post by Joel »

Hi David,

You can use ES2.GetFiles(string folder, string extension) to get all of the files in a folder with a particular extension. So to find out if any files exist in the default save folder with a a .dat extension, you should be able to do:
if(ES2.GetFiles("/", "*.dat").length > 0)
    print("true");
else
    print("false");
All the best,
Joel
drwayyyne
Posts: 5
Joined: Fri Mar 27, 2015 1:01 pm

Re: ES2.Exists

Post by drwayyyne »

Hey Joel,

thanks for the rapid reply once again! With two minor changes I got your suggestion working:
if (ES2.GetFiles("", "*.dat").Length > 0)
Thanks again,
David
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: ES2.Exists

Post by Joel »

Ah yes, that was my fault for typing it directly into the forum! Glad you got it working.

All the best,
Joel
Locked