.Ini files doesn't refresh after change

Sonata

Member
Hello guys,

do you too experience that if u change .ini files in resource tree that game maker build would still keping the data from the old one??

i experienced this many times and Clean doesn't help. Only if i change directory where the .ini file is in included files
 
Yes, this will happen.

The way Game Maker Studio works, is when you access an included file such as your ini file, it will first check the working_directory folder.

On Windows the working_directory is as follows:

  • Windows and Windows UWP- Windows has all files in the %localappdata%\<Game Name> directory (on Windows 7 this is the /Users/<User Name>/AppData/Local/<Game Name> directory).
If GMS does not find the ini file in this folder, it will check the Included Files for it. If it finds it there, it will read the data from the Included File.

Now, if you make a change to the ini file, that changed file will be saved in the working_directory folder.

The next time you run your game or try to access the ini file, as above, GMS will first look in the working_directory folder for the file. Because the file is now present in the working_directory folder, GMS will read the data from this file NOT the Included File. Even if you change the Included File in your resource tree, because there is now an ini file in your working_directory, GMS will still read the working_directory copy, not the updated Included Files ini file.

The solution would be to either:

1) Manually delete the file from the working_directory folder, then run the game. As the file is no longer in the working_directory, GMS will pick up the data from the updated Included File.

2) In your game code where you access the ini, use file_delete() to first delete the existing ini file. Then, when you try to read the ini file, the update Included File will be used.

NOTE: In a production / released version of your game, you may need to include some logic that preserves the previous ini file settings if there is any data in there that the user may have saved that needs to be kept between versions of you game. You might need to read the ini file data, keep the relevant stuff, then delete the file so the new Included File gets used, but update it with the users personalized data.

If the ini file just contains non-specific game settings that wouldn't affect the player, then you don't have to do that, just delete the ini file from the working_directory when your game starts.

It can seem a bit complicated at first, if anything doesn't make sense let me know.
 
Top