read_text_file()
On this page
read_text_file(path, fallback = "")Read the complete contents of a text file.
Returns: Text; fallback if the file is missing or cannot be opened.
read_text_file("user://notes.txt", "")write_text_file()#
write_text_file(path, text)Write the complete text, creating parent directories where needed.
Returns: Boolean success.
write_text_file("user://notes.txt", "Visited the archive.\n")Only user:// writes are accepted. Existing content is overwritten, not appended.
read_json_file()#
read_json_file(path, fallback = null)Read a text file and parse its JSON.
Returns: Parsed data or fallback.
read_json_file("user://preferences.json", {"music": 0.7})In this helper, JSON null also selects the fallback. Use from_json(read_text_file(...)) when valid null must be distinguished from failure.
write_json_file()#
write_json_file(path, value, indent = "\t")Serialize JSON and overwrite a user-data file.
Returns: Boolean success.
write_json_file("user://preferences.json", {"music": 0.5}, " ")This is a custom data file, not a replacement for a full game save.
