File error

Started by Vincent, Mon 09/04/2018 09:10:10

Previous topic - Next topic

Vincent

Okay, here we go with another silly question.
On my C: driver I have installed Adventure Game Studio 3.2.1 and on my desktop I have a folder with other Ags versions. If I open a new project with Ags 3.2.1 and do something like:
Code: ags

if (!File.Exists("temp.tmp"))
{
  File *output = File.Open("temp.tmp", eFileWrite);
  output.WriteString("some text");
  output.Close();
}

It generate the file *tmp on my compiled folder. But, if I open a new project with AGS 3.4.1.12 and do the same thing then the file doesn't get created. How do I should fix this?

Gilbert

I'm not sure what default folder recent versions of AGS would have files read from or written to(I don't even have the latest version installed ATM), and it's possible that it's now defaulted to somewhere like $APPDATADIR$ or $SAVEGAMEDIR$, to avoid problems such as being not able to write to the game's own folder if it's installed in, say Program Files.
Better follow the example in the manual to specify where the files would be read from or written to, something like:

Code: ags

if (!File.Exists("$APPDATADIR$/temp.tmp"))
{
  File *output = File.Open("$APPDATADIR$/temp.tmp", eFileWrite);
  output.WriteString("some text");
  output.Close();
}

Vincent

Thanks Gilbert for answering!

Quote from: Gilbert on Mon 09/04/2018 10:03:44
(I don't even have the latest version installed ATM)

For me, I don't have need to install the program, because if I double click the .exe it will open the editor without installing. Probably this is the problem? However, I have try your code but doesn't seems to generate the file anywhere. If I search on my computer then I got something like this.



I am not pretty sure what's going on here.

Crimson Wizard

#3
Quote from: Vincent on Mon 09/04/2018 10:20:07
For me, I don't have need to install the program, because if I double click the .exe it will open the editor without installing. Probably this is the problem?

No. It does not matter how you install or run the Editor, so long as installation is complete.
Besides, it is the game that saves files, not Editor.




If you don't specify special tag (like $APPDATADIR$ or $SAVEGAMEDIR$) AGS writes files to $APPDATADIR$, which is located in C:/ProgramData/Adventure Game Studio/<nameOfyourgame> by default.

You may modify this path in the Default Setup page, by changing "Custom shared data path" option. (Simply setting it to true and not typing anything should save files in the game directory).

For more information, please refer to the manual. Changes to how AGS games saves files is mentioned in the "Upgrading to AGS 3.3.5". Additional information may be found in "File.Open".
Also maybe useful: "Upgrading to AGS 3.4.1" and "Default setup" topics.

Note: these topics are only found in the offline manual file you have with AGS Editor, the online manual is still not updated :(.

Vincent

Thanks Crimson Wizard for answering, tips and clarifications!

Quote from: Crimson Wizard on Mon 09/04/2018 10:32:27
You may modify this path in the Default Setup page, by changing "Custom shared data path" option. (Simply setting it to true and not typing anything should save files in the game directory).

Setting this option to true it solved the issue, thanks a lot again.

SMF spam blocked by CleanTalk