Get path of exported game executable

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By vittopascu

Hello everyone, I am very new to Godot and I don’t know if what I would like to achieve is doable or if it even makes sense, here is what I have in mind:

I am implementing a “character editor” inside my 2D game and I would like the user to have relatively free access to the character graphical resources (sprites) directly from the file system. I would like the game, once exported and started, to create a folder in the same directory where the game executable is, and bring in a few default assets that are inbuilt in the game, just to give the user some context of where things are in the foreseen folder structure for the assets.

I tried to get the game’s path with ProjectSettings.globalize_path(“res://”), but it always returns the folder of the project, while I would like the path of the exported game, wherever it is in the file system.

What can I do about this issue? is there a better way to deal with the issue? Thank you in advance :slight_smile: :slight_smile:

What about using the “user://” directory?

exuin | 2021-02-15 21:38

:bust_in_silhouette: Reply From: yrtv

Edit

To be clear res:\\ may not exist in export.

From File paths in Godot projects — Godot Engine (stable) documentation in English

While the project is running, it is a common scenario that the
resource path will be read-only, due to it being inside a package,
self-contained executable, or system-wide install location.

:bust_in_silhouette: Reply From: backendcoder

You can use OS.get_executable_path()

The “equivalent” of res:// in an exported project would be OS.get_executable_path().get_base_dir(), since you want a directory path, not a file path.

Calinou | 2021-02-19 21:09