Is there a way to save and get values from the game ini file?

Hi there, is there any way to save and get values from the game ini file from blueprint? it’s a pretty necessary feature for almost every game.

Greetings.

Do these files get saved as binary files or plain text? I want my users to be able to modify certain stuff externally.

Yes there is, I’ve seen various posts about this but for me this simple solution works very well.

In this example I’m using a fixed file name and save object but you can extend this simply to work with different files and object to for example keep game settings in one file and multiple saves in another.

First create a new blureprint of type ‘SaveGame’. Name it to what you want but in my example it’s ‘PlayerObject’. Within Player Object have a variable that is a ‘User Structure’ you have created to contain all your save game info, IE Score, etc etc.

Then create another blueprint of functions and add the following functions.

You should then have a variable in your game controller which is of type Player Object. You can now call save game with that object and it will save it or return it in the case of load. I’ve seen people copying out data from the user structure to local variables then back in to save however you can work directly with your user structure and its a lot less work.

One caviate is that you must call StartNewGame Once before the above. You can do this using the function ‘Does Save Game Exist’ which will let you know if you already have a save game.

Binary I’m afraid. If you want to use a ini file text format your going to need to hit C++ to do it as I’ve not found a way.

Its on my TODO list to write an ini loader which can expose it’s self to blueprints but its way down the list atm. If you do find someone who has already done it let me know :wink:

Ow, I hope Epic implements it for 4.5 or even 4.4, it’s a really basic thing.

Save Game function does not work. do you have to cast to player item before you run save game function?

Could you post a screenshot showing your setup please?
I switched to saving gamedata your way from the complex one you mentioned, but I am having troubles. Thank you in advance

The accepted answer on here doesn’t provide a solution close to the question unfortunately due to binary / non-portable nature of save data. A binary save data file is completely different than modifying ini files at run-time. What if you want presets that designers can create in-game that save to an ini and you can propagate those through version control to other designers / programmers in the engine?

Save data doesn’t support that.