This opens an ini_file for reading and/writing. If the ini_file does not exist at the location you are checking, GameMaker Studio 2 may create one, but only if you write data to it. If you have only read information from the ini file, then the default values for the read function will be returned, but the ini file will not actually be created.

Please note that you can only have one ini file open at any one time and remember to use ini_close once you're finished reading/writing from the .ini file as the information is not actually stored to disk until then (it is also stored in memory until the file is closed).

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



Argument Description
name The filename for the .ini file.




score = ini_read_real("save1", "score", 0);

This will open 'savedata.ini' and read the score value under the section "save1" with the key "score" in it, then close the .ini again. Should there be no value under "save1", "score" or there is no "savedata.ini" file present, score will be set to 0 (the default value). Note that the ini file has been placed in the subdirectory "Settings", which is the folder that holds the INI file in the resource tree included files.