Godot Version
[4.6.2] 2D
Question
Hello again!
New conundrum: I need to access files within the executable’s folder. I have…kind-of.
Right now, the way I am doing it is a bit silly, but it is as follows:
var exePath = "/"
func _ready() -> void:
var rebuild = str(OS.get_executable_path()).split("/")
print(rebuild)
rebuild.remove_at(len(rebuild)-1)
rebuild.remove_at(0)
print(rebuild)
for ii in len(rebuild):
exePath += rebuild[ii] + "/"
print(exePath)
This worked perfectly for .txt files, so long as I simply append them accordingly. However, attempting to instead append a .png, .otf, or otherwise returns:
E 0:00:00:809 Maker.gd:114 @ Styles(): No loader found for resource: {PATH TRUNCATED} (expected type: unknown)
<C++ Error> Method/function failed. Returning: Ref<Resource>()
<C++ Source> core/io/resource_loader.cpp:358 @ _load()
<Stack Trace> Maker.gd:114 @ Styles()
Maker.gd:64 @ Manage()
Maker.gd:23 @ _ready()
This is odd. I would further suspect load(), but if I am to instead pull from res://, in the editor (by simply replacing exePath with “res://”), it works just fine. The files are indeed in the appropriate file location, too.
The error message was pulled from a png, specifically for assignment to a button. I’ve put the Styles() function below accordingly, though the error still occurs outside the function.
Styles()
func Styles(type, loader, _margin):
ActiveStyles.append(StyleBoxTexture.new())
ActiveStyles[si].set_texture(load(exePath + loader))
#commented code removed
ActiveInstances[i].add_theme_stylebox_override(type, ActiveStyles[si])
si += 1