|
||
FilesIt is useful to use external files in games. For example, you could make a file that describes at what moments certain things should happen. Also you probably want to save information for the next time the game is run (for example, the current room). The following functions exist to read and write data in text files:
file_text_open_read(fname) Opens the file with the indicated name for reading. The function returns the id of the file that must be used in the other functions. You can open multiple files at the same time (32 max). Don't forget to close them once you are finished with them. To manipulate files in the file system you can use the following functions:
file_exists(fname) Returns whether the file with the given name exists (true) or not (false). The following functions can be used to change file names. Note that these functions do not work on the actual files they only deal with the strings.
filename_name(fname) Returns the name part of the indicated file name, with the extension but without the path. In rare situations you might need to read data from binary files. The following low-level routines exist for this:
file_bin_open(fname, mod) Opens the file with the indicated name. The mode indicates what can be done with the file: 0 = reading, 1 = writing, 2 = both reading and writing). When the file does not exist it is created. The function returns the id of the file that must be used in the other functions. You can open multiple files at the same time (32 max). Don't forget to close them once you are finished with them. If the player has checked secure mode in his preferences, for a number of these routines, you are not allowed to specify a path, and only files in the application folder can e.g. be written. If you included files in the game executable and did not automatically export them at the start of the game, you can use the following functions to do this.
export_include_file(fname) Exports the included file with the name fname. This must be a string variable, so don't forget the quotes. The following four read-only variables can be useful:
game_id* Unique identifier for the game. You can use this if you need a unique file name. 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. The actual parameters can be retrieved with the following function. You can read the value of environment variables using the following function:
environment_get_variable(name) Returns the value (a string) of the environment variable with the given name. |
||
|
||
|
You can also read this manual on one single long page (± 1.5 mb)
Also available in: ![]() Download helpfile
|
||





