How to load txt files?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By vania23

So basically i was trying to load a txt file for some purposes but the best i was able to load was <Object#null> . is there any way to load them though?

:bust_in_silhouette: Reply From: jgodfrey

Sure, you can load a TXT file. You’ll want to check out the docs for the FileAccess object here:

Here’s an example (taken directly from the linked docs page) that should be close to what you need…

func load():
    var file ="user://save_game.dat", FileAccess.READ)
    var content = file.get_as_text()
    return content