.Ini files doesn't refresh after change

Discussion in 'Programming' started by Sonata, Apr 9, 2019.

  1. Sonata

    Sonata Member

    Joined:
    Jul 31, 2017
    Posts:
    14
    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
     
  2. IndianaBones

    IndianaBones Member

    Joined:
    Jul 5, 2016
    Posts:
    2,048
    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.
     
  3. Sonata

    Sonata Member

    Joined:
    Jul 31, 2017
    Posts:
    14
    Hey @IndianaBones

    Thanks for such a complex description :-D i read it all and now i am happy to use your solution 1

    Edit: I already use it and it works so thank you very much :)
     
    IndianaBones likes this.
  4. IndianaBones

    IndianaBones Member

    Joined:
    Jul 5, 2016
    Posts:
    2,048

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice