What does error mean: "ERROR: scene/resources/resource_format_text.cpp:40"

Godot Version

Godot 4.5 stable

Question

I’m trying to add a save/load system for the level editor in my game. I implemented a simple test save and load, and it seems to work fine from my testing, but I still get this error whenever I load the project:

ERROR: scene/resources/resource_format_text.cpp:40 - res://addons/gaia_sys/map.tres:1 - Parse Error: .
ERROR: scene/resources/resource_format_text.cpp:878 - Condition "error != OK" is true.

Here’s my save/load script.

@tool
extends TileMapLayer

const Map_Path = "res://addons/gaia_sys/map.tres"

var map_file : FileAccess
var rooms : Array = ["potato"] # random debug value

func _ready() -> void:
	if FileAccess.file_exists(Map_Path): # detects if the file already exists.
		map_file = FileAccess.open(Map_Path, FileAccess.READ) # opens the file to read.
		rooms = map_file.get_var() # loads the array from the file into a variable.
		print(rooms) # print for debugging
		map_file.close() # close the file
	tile_map_data.clear() # clear the tilemap (unrelated to the issue)

func add_room(position:Vector2i): # add room to the map (also unrelated)
	set_cell(position, 0, Vector2i(1, 0))

func save_map():
	print("save!") # debug save message
	map_file = FileAccess.open(Map_Path, FileAccess.WRITE_READ) # opens and trunkates file
	map_file.store_var(rooms) # save variable to file
	map_file.close() # close file
	print(FileAccess.file_exists(Map_Path)) # debug message to confirm file

Don’t use tres extension in the filename.

Alright. What file extension should I use?

*.edf

thanks!

Sorry for bothering you guys so much. I appreciate your patience though.

It stands for “endercopp’s data file” :wink:

You can use any extension as long as it’s not an extension that Godot recognizes as one of registered resource formats. The engine automatically scans project’s file system for resources. If it finds a file with a registered extension but file’s internal structure doesn’t match the extension - the error will be reported as the engine will think the resource file is corrupted.

2 Likes

okay! duly noted XD