working_directory

This returns a path that points to where the game's files are stored.

In most cases, this is the same as the program_directory, which is the path to the game's runner (executable). However if the game's files happen to be in a different directory than the runner (say you use game_change to use a different working directory or use command line to run a runner in a different location), then this will point to where the game files are, not the runner.

It may also be a different directory when testing your project through the IDE, as then the game files and the runner are in different locations as well.

When using this directory to write out a file, GameMaker will redirect it to the game_save_id location if the file system sandbox does not allow writing to the working directory (this is the default behaviour, which can be disabled in the Game Options for Desktop targets only).

WARNING This may not work as you expect due to GameMaker being sandboxed! Please see the section on The File System for more information.

WARNING GameMaker doesn't limit writing to this directory so whether this is possible depends on OS permissions. It is however discouraged that you write to working_directory, as it is possible to damage the game installation this way.

NOTE The working_directory variable stores the path including the final slash.

 

Syntax:

working_directory

 

Returns:

String

 

Example:

ini_open(working_directory + "temp_ini.ini");

This will open an INI file from the working directory of the game (creating it if it does not already exist). This could be the save area or the program directory depending on the sandbox level.