Godot Version
4.1.1.stable
Question
I’m having problems with this function.
func effectBuilder(path:String):
var dir = DirAccess.open(path);
if not dir: print("[EFFECTBUILDER] Directory \"", path, "\" does not exist..."); return;
dir.list_dir_begin();
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;
print(path+file_name);
var tres := ResourceLoader.load(path+file_name); #THIS LINE DOESN'T WORK?
print(tres);
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 tres.id
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?