Jump to content


Photo

The file_exists function isn't working


  • Please log in to reply
2 replies to this topic

#1 MrPerson300

MrPerson300

    GMC Member

  • GMC Member
  • 15 posts
  • Version:GM:Studio

Posted 25 May 2012 - 03:50 PM

I am working on a block building game that uses the file_exists function to detect weather or not there is a save file so it can decide weather to generate new terrain or to load the save file. In GM: HTML5, this worked fine, but in Studio, the file_exists function always returns false, even if a save file does exist. This is the code I used:

if (file_exists(%localappdata%/GameName/save.sav"))
{
  load("%localappdata%/GameName/save.sav");
}
else
{
  generate_terrain();
}

Even if there is a save file in that directory, file_exists still returns false. Any help would be appreciated, thanks!
  • 0

#2 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 17017 posts
  • Version:GM:Studio

Posted 25 May 2012 - 04:11 PM

Try using working_directory instead of the &localappdata%...
  • 0

#3 MrPerson300

MrPerson300

    GMC Member

  • GMC Member
  • 15 posts
  • Version:GM:Studio

Posted 25 May 2012 - 05:10 PM

That seemed to work, thanks!

Edit: Wait a minute, this didn't work as well as I'd thought. I also need to save an INI file in addition to the text file, but the ini file won't save anywhere other than in the %localappdata% directory for some reason. However, when I try to use that directory, the file_exists function stops working.

Edited by MrPerson300, 25 May 2012 - 06:15 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users