0 votes

Is it possible to make Godot save vars in a file as human readable?

        var file = File.new()
        file.open("./thisfile.txt", File.WRITE)
        file.store_var(position) #Unreadable
        file.store_string(str(position))
        file.close()

If I open the created file with notepad or whatever, the first store creates unreadable text. This also happens with store of numeric types, such as float and double.

Is there a way to make it so that Godot saves the vars, or anything that isn't a string, as plaintext that can be edited manually later?

Godot version 3.3.4
in Engine by (294 points)

You can try using the JSON. If these are configuration files, you can also try the ConfigFile class.

1 Answer

0 votes

I don't know about those methods of File class, and I don't know how to convert JSON into easily readable file, but I know how to transform variables into strings :
You should use str2var() and var2str() methods

Or if You meant You need all your variables names :
getscriptproperty_list()

It is called on script class, I hope it helps

by (7,925 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 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.