Problems with ResourceLoader

Godot Version



I’m having problems with this function.

func effectBuilder(path:String):
	var dir =;
	if not dir: print("[EFFECTBUILDER] Directory \"", path, "\" does not exist..."); return;
	var file_name = dir.get_next();
	while file_name != "": 
		if dir.current_is_dir(): file_name = dir.get_next(); continue;
		if file_name.split(".")[-1] != "tres": file_name = dir.get_next(); continue;
		var tres := ResourceLoader.load(path+file_name); #THIS LINE DOESN'T WORK?
		file_name = dir.get_next();

The line that is not working as intended is the 3rd from the bottom.

My intention is that this function will search through an entire folder of .tres files and reference data stored on them. For example…

I want to call and have it return “burn”, but when I do, it gives a runtime error. Apparently, the resource isn’t loading as my “StatusEffect” class. (I also tried ResourceLoader.load(path+file_name) as StatusEffect, same result).

When I don’t try printing parameters from the Resource, the game runs fine, but it prints this error:

Referencing this line:

Any ideas?

maybe bugs in the engine, I don’t remember exactly how I fixed the other problems:

The variable is now suddenly found, but I don’t know why. I have inserted many ‘print’ outputs and restarted Godot Editor after the conversion. v4.1 to v4.2

1 Like

Thanks for linking me to this!

After reading through the thread, I saw someone suggest removing _init() from the super-class file, and that seemed to solve the issue.

1 Like

ok maybe v4.1 issue

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.