0 votes

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://?


in Engine by (34 points)

1 Answer

+1 vote
Best answer

It's explained here: https://docs.godotengine.org/en/3.1/classes/class_projectsettings.html#class-projectsettings-property-application-config-custom-user-dir-name
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.

by (29,088 points)
selected by

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

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: https://docs.godotengine.org/en/stable/classes/class_os.html#class-os-method-is-debug-build
Could be OS.has_feature("standalone")

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.