I’m making a level editor and I would want the player to be able to create files and give them a name with the usual “saving file window”. I’d also like for the player to be able to pick a file in the same kind of window so the game reads it. Is there any way or should I find a different sistem to open files (I can work with that)?
You can use the FileDialog node with the signal file_selected(path: String).
Read the documentation here if you want to see what else it can do.
For saving and reading files, you will want to use FileAccess.open like the following examples:
Writing
func on_file_selected(path: String) -> void:
var file = FileAccess.open(path, FileAccess.WRITE) # Write to the file
file.store_string("Hello from Godot!")
file.close()
Reading
func on_file_selected(path: String) -> void:
var file = FileAccess.open(path, FileAccess.READ) # Read from the file
var file_as_text = file.get_as_text()
file.close()
NOTE: on_file_selected is connected to the signal file_selected
Read the documentation here if you want to see what else it can do.
Thanks a lot!