I added the file as an included file, but the game code wouldn't write anything to the INI file. Here's my code:
Code:
var inipath="settings.ini";
FS_file_text_set_endl_windows();
show_message("inipath="+inipath);
if(FS_file_exists(inipath))
{
show_message("Ini file exists. Now opening it.");
OptionsFileHandler=FS_ini_open_ext(inipath);
show_message("SettingsFileHandler="+string(SettingsFileHandler));
}
else
{
show_message("Ini file doesn't exist. Now making it.");
var handler=FS_file_text_open_write(inipath);
FS_file_text_writeln(handler);
FS_file_text_close(handler);
SettingsFileHandler=FS_ini_open_ext(inipath);
show_message("SettingsFileHandler="+string(SettingsFileHandler));
}
FS_ini_write_string_ext(SettingsFileHandler,"Test","Test","Test");
if(show_question("Wanna close the INI file?"))
{
FS_ini_close_ext(SettingsFileHandler);
}
I've read that GMS has this weird bundling/sandboxing system because of which writing to the included files is not allowed. This code works when the file isn't included. In both cases, the compiler creates a new temporary folder in C:\Users\Zvoc47\AppData\Local\gm_ttt_somenumber named gm_ttt_someothernumber each time I click to run the game.
I tracked down the files of the Hello Mario Engine and tried changing the program with show_message lines of code. Each time I ran or compiled the game, it perfectly saved the files to C:\Users\Zvoc47\AppData\Local\HelloMarioEngine. Why doesn't it do that to my game?
However, if I export my game in zip format, extract it and run it, all the files go to the same folder where the game runtime is contained.
Keep in mind that I'm using the functions of the GMFileSystem whereas the Hello Mario Engine uses the built-in file I/O functions. I need to use GMFileSystem because I want to implement a painting feature where the player can paint their own avatar sprite in the game and save it to the characters folder of the game and use it for online battles or sharing with their friends. GMFileSystem can import and export sprites as well as export surfaces that the player will paint their character on.