• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

GMS 2.3+ Storing files in resource tree folder

jonjons

Member
hello everyone.
I now this has been an issue due to sandBox or compatibility with mobile devices.

but now with gm2.3 is there an option to store files like ( save games, inventory list, etc... ), in a costum folder on the resource tree ?
 

kburkhart84

Firehammer Games
Even before version 2.3, you could save files in the resource tree. Those files are automatically added to the project's working_directory folder. This is a good place to put any assets that aren't handled in the IDE, like if you have an external level editor, or 3d models, or any number of things like that.

Save-game type files are normally not good candidates for this type of file though. Instead, your game should just be creating them as needed(and not relying on them being in the project folder structure).
 

jonjons

Member
Even before version 2.3, you could save files in the resource tree. Those files are automatically added to the project's working_directory folder. This is a good place to put any assets that aren't handled in the IDE, like if you have an external level editor, or 3d models, or any number of things like that.

Save-game type files are normally not good candidates for this type of file though. Instead, your game should just be creating them as needed(and not relying on them being in the project folder structure).
that is what i was hopping to store, not exacly 3d, but an animation stuff wirten in json.
but how do you save them to a folder ? And how are they accessed ?
by default they are stored in user\userName\appData
 

kburkhart84

Firehammer Games
If they are part of the "included files" that are in the datafiles folder in the project folder(2.3 and newer), then they automatically get exported to the working_directory folder(as you can see showing up as the appData folder). If you can look in the manual, it will tell you how to access those files using the file functions.
 

jonjons

Member
If they are part of the "included files" that are in the datafiles folder in the project folder(2.3 and newer), then they automatically get exported to the working_directory folder(as you can see showing up as the appData folder). If you can look in the manual, it will tell you how to access those files using the file functions.
Ive looked in the manual, i just dont know the correct way of doing it. It doesnt mention anything about saving to a resource tree folder, and access them the same way gm accesses a prite or object. The best options seem to be directory_create(dname) / directory_exists(dname)... the working_directory "%LOCALAPPDATA%/gamedir/" was the one i was trying to avoid.
 

kburkhart84

Firehammer Games
Well, the working_directory is going to be exactly where those files end up. I don't know any reason why you should worry about avoiding that. It has been the standard in Windows app development to use that folder instead of the actual program directory for quite some time now. Care to share why you don't want to do it the normal/recommended way?
 

jonjons

Member
Well, the working_directory is going to be exactly where those files end up. I don't know any reason why you should worry about avoiding that. It has been the standard in Windows app development to use that folder instead of the actual program directory for quite some time now. Care to share why you don't want to do it the normal/recommended way?
no special reason, just trying to avoid end up with 50 / 70 files in here
 

kburkhart84

Firehammer Games
no special reason, just trying to avoid end up with 50 / 70 files in here
OK, so if you are on 2.3 and up, you can make folders inside the datafiles folder of the project directory, and then you just access the files the same way at run-time, just using those folders. My input system has to do this since I store settings using this system and I put those files into a folder instead of at the root level.

The other cool part about the new way is that you can externally update and move the files around within that datafiles folder, and you don't have to do anything to let the IDE know, it just automatically works. You still have to change your code if you move something, but the IDE no longer cares...and the IDE no longer stores the file like the older way, where you had to manually re-import it each time.
 

jonjons

Member
OK, so if you are on 2.3 and up, you can make folders inside the datafiles folder of the project directory, and then you just access the files the same way at run-time, just using those folders. My input system has to do this since I store settings using this system and I put those files into a folder instead of at the root level.

The other cool part about the new way is that you can externally update and move the files around within that datafiles folder, and you don't have to do anything to let the IDE know, it just automatically works. You still have to change your code if you move something, but the IDE no longer cares...and the IDE no longer stores the file like the older way, where you had to manually re-import it each time.
but how can do you do it ? Is it ok to just move the files inside a folder like its done with a sprite ?
 

kburkhart84

Firehammer Games
With sprites, you have to create them in the IDE and use the IDE to import the files. With this, you can just use the Windows File Explorer to put the files there. Inside the project folder is another folder named "datafiles." You can create another folder there for these things, even a whole tree of folders for organization. Once you put the files in that folder, the IDE will see them automatically and you don't have to do anything else.
 
Top