How to save in-game data in a text-file?

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

So I’m trying store some data (scene locations) in text file, So i can load it when my game runs.

var fp:File = File.new()
fp.open("res://Enemy/enemy_list.txt",File.READ)
while not fp.eof_reached():
	var l = fp.get_line()
	if fp.file_exists(l):
		AllEnemyPS.append(load(l))

I created enemy_list.txt beforehand. I am not able to import it inside my project, so it is visible inside the editor.
I just placed the text file inside the Enemy/ folder. But the code only works on editor not when build.
I have looked in the Resources class there is a sub-class TextFile, which I created but there is not any method in the class to access the data.

Is there is any other way to achieve this?
Thank you for taking your time.

:bust_in_silhouette: Reply From: jgodfrey

While I haven’t really investigated this, I’d guess it’s related to how resources are packaged into a build. See my lengthy answer to a similar issue here:

https://forum.godotengine.org/59637/cannot-traverse-asset-directory-in-android

So after loading with ResourceLoader as you suggested how can read the contents of the text file.

_nabajit | 2020-05-19 17:32

Is the enemy_list.txt file not being found, or is it not finding the files that are referenced inside the enemy_list.txt file?

If possible, post the contents of the enemy_list.txt file as well as the folder structure defining where the files it references are located…

jgodfrey | 2020-05-19 17:41

:bust_in_silhouette: Reply From: _nabajit

I found the solution through a reddit link
You just need to specify non resource types in export menu.
documentation link

Should have read the documentation. :slight_smile: