GM: working directory

From GMpedia.org Wiki

Jump to: navigation, search
The correct title of this article is working_directory. It appears incorrectly here because of technical restrictions.

working_directory

Type: variable
Globalism: Global
Editable: No

The working_directory variable is a global variable in Game Maker that returns the executable's "working directory".

Many people assume that working_directory returns the location of the EXE, however it doesn't necessarily return it. To get the location, use parameter_string(0).

If the game is directly opened, the working directory will be the same as its location, however, if opening another file or executable prompted the running of the game executable (i.e. if making a text editor and double clicking the .txt file thus launching the executable), the location of the initially opened file will be returned.

[edit] Game Maker Manual

  • game_id. Unique identifier for the game. You can use this if you need a unique file name.
  • working_directory. Working directory for the game. (Not including the final backslash.)
  • temp_directory. Temporary directory created for the game. You can store temporary files here. They will be removed at the end of the game.
In certain situations you might want to give players the possibility of providing command line arguments to the game they are running (for example to create cheats or special modes). To get these arguments you can use the following two routines.
  • parameter_count() Returns the number of command-line parameters (note that the name of the program itself is one of them.
  • parameter_string(n) Returns command-line parameters n. The first parameter has index 0. This is the name of the program.

[edit] See Also

Personal tools