• 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!

GameMaker Referencing Included Files

FacesOfMu

Member
Took me a while to figure this out as the docs was a little light on it. I'm posting it here in case any other users are searching for it and need it.
To reference an included file your code might read:
Code:
var file = file_text_open_read("this_file_name.csv");
BUT

If you've put your Included Files into a sub-group, the file name will need the name of that group and two backslashes \\ after:
Code:
var file = file_text_open_read("this group name\\this_file_name.csv");
When we refer to other assets in GMS2, we don't have to worry about their group names, but as the file system creates a literal folder directory with the name of your sub-group, you need to add it to the file name and use the correct separators.
Also, it's two backslashes as the first backslash tells the IDE that in this string there is a special character here, and the second backslash says that special character is a backslash (and not n for newline as in "\n" or t for tab as in "\t").
 
B

blane todd

Guest
Thank you for sharing this! There are a LOT of areas of the documentation that leave a bit to be desired. Glad i found this today.
 

Bart

WiseBart
Just to add to this, do note that a forward slash "/" as the separator works equally well and also keeps your project compatible with other platforms.
 
Top