How to I implement a player data save system in Visual Script?

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

I know there is a way to implement a save function in GDscript using the but I can’t seem to find a way or tutorial or anything if it’s even possible. I can’t find any way to use in visual script or anything. I can’t switch to GDscript because I have already put in a lot of code for my game and I don’t know it. Please if someone knows how to implement a save system using Visual Script. (For a clicker game)

:bust_in_silhouette: Reply From: eddex

I’m not familiar with VisualScript, but you should be able to use a ConfigFile for this.

it’s not possible to access the Config File stuff in visual script. You can’t do anything with files in visual script

neo | 2020-09-12 19:48

:bust_in_silhouette: Reply From: Magso

You’ll have to use an autoload/singleton gdscript and call save and load functions from the visual script. Here are the save and load functions

func save_game_cfg(data, file_name: String = "Saved Data", section_name: String = "Section", key_name: String = "Key"):
    var save_dir = "user://" + file_name + ".cfg"
    var configFile =
    configFile.set_value(section_name, key_name, data)

func load_game_cfg(file_name: String = "Saved Data", section_name: String = "Section", key_name: String = "Key"):
    var load_dir = "user://" + file_name + ".cfg"
    var configFile =
    var err = configFile.load(load_dir)
    if err == OK:
        var data = configFile.get_value(section_name, key_name)
        return data