Custom user dir, asking for explaining

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

Actually in settings, we got: Set custom user dir, to change from for example: %appdata%/Godot to a custom dir, right?

How can I set to same game folder (bin)? Just use res://?


:bust_in_silhouette: Reply From: Zylann

It’s explained here: ProjectSettings — Godot Engine (3.1) documentation in English
And also in the hover tooltip.
You cannot use this to target the folder of the executable.

When you use file paths in your games, the path will be relative to the executable already. So if you save a file with the following path "test.txt" and no prefix, it will look for a text.txt file next to the game executable. res:// cannot be used to save files because it relates to game resources (it only works in the editor).

The reason why user:// is recommended and points to a location which is not next to the executable is because not all platforms allow you to do this.

hi, i do understand this now, thanks a lot
but if i may ask one more detail…

regarding DEV and RENDER as an executable, we cannot use the same path during development and for the rendered app… so what is the suggestion here ?
i am thinking of an external config file that can be later adjusted to the installed app… in this case, we dont have to worry about the path… is there a better option ? thx

uriel | 2020-09-25 13:24

I don’t know about this. The way I handled that in my game was to use a different subdirectory in the appdata folder, based on a debug flag. I wonder if there is a function telling you if the game runs as an exported build or from an editor build?
This gives some info: OS — Godot Engine (stable) documentation in English
Could be OS.has_feature("standalone")

Zylann | 2020-09-25 14:22

haaa… very interesting ! thanks… i will try right now to apply a condition in this case, to drive the path. cool !

uriel | 2020-09-25 16:57