This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I have a game that I have installed from the play store and the application creates a file when it starts. the problem is that when i do an update to the game the old save file gets deleted or overwritten. how can i fix this?

my file code in global script:

var save = {
    "value1": 1,
    "value2": 1,
    "value3": 1,

    }
func _ready():
    load_data()
    save_data()

func save_data():
    var file = File.new()
    file.open("user://save77", file.WRITE_READ)
    file.store_var(save)
    file.close()

func load_data():
    var file = File.new()
    if not file.file_exists("user://save77"):
        return false
    file.open("user://save77", file.READ)
    save = file.get_var()
    file.close()
    return true
Godot version 3.3.3
in Engine by (60 points)

You can save it online online or use custom dir that doesn't deleted with app. Learn how to do it here (GitHub/Godot/Issues), EXOMODE's comment contains the answer

1 Answer

0 votes
func save_data():
    var file = File.new()
    if not file.file_exists("user://save77"):
        file.open("user://save77", file.WRITE_READ)
        file.store_var(save)
        file.close()
by (6,942 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.