Defold Persist provides a simple interface for saving and loading data in a Defold game engine project.
Please note that there are other wonderful modules out there that aim to solve the persistency problem, so feel free to have a look at those as well. Persist mainly focuses on simplicity and ease-of-use. I used this module in Cx6 and will continue to use it in the future.
If you have access to any of the platforms that aren’t listed in the documentation (most of them!) then please consider calling persist.save() or simply just:
-- File doesn't have to actually exist.
-- Simply returns the standardized save location as a string.
print(sys.get_save_file("Test App", "settings"))
Then either submitting a pull request or commenting on this thread with the output. I’d like to provide support for all platforms, but I don’t have access to many of them. Thanks!
On Linux, sys.get_save_file() defaults to ~/.{app_name}/{file_name}, e.g. /home/potota/.MyGame/save0. This is not great since it clutters up the user’s home folder. DefSave modifies the app name you give it so that files save to ~/.config/{app_name}/{file_name} instead, like other engines do:
Technically, it should be {config}/{app_name}/{file_name} where config is the environment variable XDG_CONFIG_HOME - defaulting to ~/.config if that’s not set. This is what Unity does, according to their docs.
I added automatic JSON support for files that have the .json extension. This means that you can persist.save() and persist.load() data directly to and from JSON files. Please let me know if you run into any problems.