Is there a way to test if a resource exists before calling load()
? For a practical use case, consider a load_face()
function:
func load_face(name: String)
ears_resource = load("res://%s/ears.png" % name)
nose_resource = load("res://%s/nose.png" % name)
eyes_resource = load("res://%s/eyes.png" % name)
mouth_resource = load("res://%s/mouth.png" % name)
beard_resource = load("res://%s/beard.png" % name)
moustache_resource = load("res://%s/moustache.png" % name)
Calling load_face("debbie")
loads Debbie's features from the corresponding folder, and her beard and moustache resources are null which all makes sense. But -- this results in numerous Resource file not found
errors being logged because you asked Godot to load a non-existent beard and moustache resource.
Is there some way to maintain this design without printing out errors?