0 votes

I am having a problem with saving through the Config File. With the application running the script works perfectly, on PC and android. However, when I close the app and restart, only the PC is recognizing the save file, android does not. I have tried to use all possible extensions (.cfg, .txt, .tres, .sav, etc.) and I have also used the recommended path ("user: // file"), without success. I've already checked if the file was being created and it was, but it wasn't being read by the app, and I don't know why. The code for SaveSystem, load and save is below:

savesystem:

extends Node

var save_path = "user://redacao_salva.cfg"
var config = ConfigFile.new()
var load_response = config.load(save_path)

func _ready():
    config.load(save_path)

export var redacao = {
    titulo1 = "",
    texto1 = "",

    titulo2 = "",
    texto2 = "",

    titulo3 = "",
    texto3 = "",

    titulo4 = "",
    texto4 = "",

    titulo5 = "",
    texto5 = ""
}


func saveValue(section, key):
    config.set_value(section, key, redacao)

    config.save(save_path)

func loadValue(section, key):
    config.load(save_path)
    redacao = config.get_value(section, key, redacao)

save in running:

func _on_Button2_pressed():
    $ColorRect/esceverredacao/ColorRect2/menu/mensagem_salvar.visible = true
    yield(get_tree().create_timer(2.0), "timeout")
    $ColorRect/esceverredacao/ColorRect2/menu/mensagem_salvar.visible = false
    var tema = $ColorRect/esceverredacao/ColorRect2/tema.text
    var redacao = $ColorRect/esceverredacao/ColorRect2/redacao.text

    var redacao_salva = {
    titulo = tema,
    texto = redacao
    }


    var save_file = get_node("/root/SaveSystem").redacao
    save_file["titulo1"] = redacao_salva["titulo"]
    save_file["texto1"] = redacao_salva["texto"]

    get_node("/root/SaveSystem").saveValue("Redacao", "Redacao")

load in running:

func _ready():
    SaveSystem.loadValue("Redacao", "Redacao")
    var load_ = get_node("/root/SaveSystem").redacao

*Remembering that this scheme works perfectly on the PC and the file is generated and read by the app normally, the problem happens when I install the .apk on android. The saving happens with the app running, the file is generated, but the app does not read the information when restarted.

in Engine by (27 points)

Please log in or register to answer this question.

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.