0 votes

Godot 4 Vedta 2
With the new file system, I can't read the saved objects.

The problem seems to be, that it can't decode the objects.
I understand that you have to put "true" as a parameter in the storevar and getvar methods for that effect.
In version 3 I had no problem.

func save_ships():
    var path = "res://factions_data/" + Global.faction + ".ships"
    var file = FileAccess.open(path, FileAccess.WRITE)
    file.store_var(ships, true)

func load_ships():
    var path = "res://factions_data/" + Global.faction + ".ships"
    if FileAccess.file_exists(path):
        var file = FileAccess.open(path, FileAccess.READ)
        ships = file.get_var(true)

When the process reaches ships = file.get_var(true) stops.
The debugers says: Parser Error: Class "Ship" hides a global script class.
The output says: editor/debugger/debugadapter/debugadaptertypes.h:70 - Condition "path.isempty()" is true.

The variable ships is an array of objects made with a custom class, named "Ship".

Godot version Gofot 4 Beta 2
in Engine by (36 points)

Adding a comment because I doubt this answers it, but try to use the user:// folder instead of res://.

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.