0 votes

I am newish to Godot, and have checked just about everything I can find on this issue, with no luck. I am trying to make a system where when the player does something, a text file appears in the folder that the game is being run from. My code for this is like so:

var __my_file := File.new()
var __my_text := str("test_text")

Then, I call this when I save to the .txt file.

    __my_file.open("res://Test.txt", __my_file.WRITE)
    assert(__my_file.is_open())
    __my_file.store_string(__my_text)
    __my_file.close()

When running the game from the editor, this works totally fine. The text file shows up in the main res:// folder. However, when I export the game, the .txt file doesn't show up in the folder the .app is running from, nor any of the surrounding folders. I am using the default MacOS export settings, with *.txt in the force export line, to no avail. I cannot figure out how to do this.

Godot version Godot v3.2.3.stable.official
in Engine by (29 points)

1 Answer

0 votes

You cannot write to res:// after exporting.
Instead you can write to user://

On windows you can find this somewhere in
%appdata%/Godot\app_userdata/project_name

Under Linux i think it is in
~/.local/share/godot/app_userdata/project_name
(unsure)

More info about this: Link

by (1,412 points)
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 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 webmaster@godotengine.org with your username.