• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM How can I open a file for reading in the %appdata% location?

Anixias

Member
In order to just be able to find the files I have defined in this location, I had to do this:
Code:
var dir = working_directory;
dir = string_copy(dir,1,string_pos("Local",dir)-1);
dir += "Roaming\Anetia\";
Anetia is the name of my game btw.

Anyway, I am able to find files in dir+"Data\Items\*.json", but I cannot actually open them for reading. GameMaker refuses to open them.

And, yes, I need these files to be in this location. They need to be findable by players so they can mod the game, and need to be easily findable by me, so I can update the game.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
You don't need to do any of that - if you do not specify the directory (e.g. file_text_open_write("some.txt")), it goes to appdata automatically. Akin with reading - the game will first look if there's the file in appdata, and check included files if there isn't.
 

Anixias

Member
I've already tried just reading:
file_find_first("\Data\Items\*.json",0);
but it does not work...

EDIT:
If I attempt that above, I get this:
Error! not allowing save with filename 'C:\Data\Items\*.json'
which is not the right area. However, if I use the dir variable I defined above, it can find the files, but fails to open them for reading.

EDIT2:
Removing the first backslash before Data fixes the issue... Now my issue is I can't properly read Unicode-encoded text files, so I can't have native Japanese reading support :(
 
Last edited:
Top