Can you use a .cfg save system without creating an external file?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MOSN

So in my project I use a .cfg file for storing options and unlocked achievments and it works perfectly fine. But when exporting the game the file (SaveFile.cfg) is created seperately from the .exe making it incredibly simple to just open up and edit.
If I add *.cfg to the export filter it seems to sort of work (the options that I’ve set are carried over, so the file must be there), but when the game is supposed to save something to the file it instead creates a new one seperate from the .exe.

If its relevant my functions for saving and loading look like this:

var save_path = “res://SaveFile.cfg”
var config = ConfigFile.new()
var load_repsone = config.load(save_path)

func saveValue(section, key, value):
config.set_value(section, key, value)
config.save(save_path)

func loadValue(section, key):
return config.get_value(section, key, 0)

:bust_in_silhouette: Reply From: caprinae

I don’t mean to sound rude, but have you considered simply not worrying about it? Players will pick apart your game in ways that you never expect. They will export your assets and read your code. They will use things like Cheat Engine to get infinite health, and achievement unlockers if you release your game on a platform like Steam. Even if you hide the save file somewhere, they will find it and they will create guides and tools to help people edit it anyway.

My recommendation would be to just let it go and not worry about it. Some people who go looking for the save file just want to make a backup copy, and by hiding it you would be denying that option to them. Your efforts are better spent on making your game into an excellent experience.

There is a way to encrypt your save if you want to add an extra step.

The article:
https://docs.godotengine.org/en/3.2/tutorials/io/encrypting_save_games.html

But, as stated above, people will find a way and pick it apart if they really want to. People pick apart AAA titles, Indie titles will be cake work. Don’t stress about it, if you can help it.

Aireek | 2020-04-15 00:50

Thanks for that, I didn’t know there was a built-in function to do this! You should post that link as an answer to this question so that it can be documented properly, since it technically is the actual solution.

caprinae | 2020-04-15 01:58

:bust_in_silhouette: Reply From: Aireek

There is a way to encrypt your save if you want to add an extra step.

The article:
https://docs.godotengine.org/en/3.2/tutorials/io/encrypting_save_games.html

But, as stated above, people will find a way and pick it apart if they
really want to. People pick apart AAA titles, Indie titles will be
cake work. Don’t stress about it, if you can help it.

Moved to an answer as requested, Thanks and goodluck!

Thanks, I’ll try to see if I can make this work.
And yea of course people can find a way to cheat if they really want to, but I figured I’d at least not make it as easy as just opening a file in notepad and changing a few numbers.

MOSN | 2020-04-15 09:02