0 votes

Hello, i'm using the code below to load a resource (that i use as save file).
When it find a save file it loads it, when it no, it prints "no save file"

If i launch the project from debug it works correctly, but if i export the project it doesnt: sometimes, even after i delete the savefile from the folder, it loads an "old" file (i dont honestly know where does it load from)
The funny thing is it does not happens all the time: when it does, i have to re-export the project, and then it works correctly till it breaks again.

I'm not sure if this is caused by some bug in my code or some intrisic behaviour of how the resources are stored in memory?

func load_from_file():
    var file=File.new()
    if file.file_exists("res://Saves/SaveGame.res"):
        print("There is no save file")
Godot version 3.4.2 - 3.3.2
in Engine by (1,500 points)

1 Answer

+1 vote
Best answer

Have you tried using user:// instead of res:// for storing your save files? Does this have the same issue?

My understanding is when you export a game, it does some clever magic to pack all the files... It abstracts away the concept of res://, so I'm not sure how saving loading works in that context... Like, is the file appearing in your executable directory?

by (1,342 points)
selected by

it works, and it looks much more stable than before, thanks for the suggestion!
As i was expecting, the answer was magic.
Dont meddle with magic kids!

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.