FileAccess Godot 4 Beta 2

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

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 store_var and get_var 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.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.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/debug_adapter/debug_adapter_types.h:70 - Condition “path.is_empty()” is true.

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

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

Kyle Szklenski | 2022-10-09 11:54