0 votes

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.

in Engine by (26 points)

2 Answers

0 votes
Best answer

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. :)

by (26 points)
selected by
0 votes

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://godotengine.org/qa/59637/cannot-traverse-asset-directory-in-android

by (10,916 points)

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

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...

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 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 webmaster@godotengine.org with your username.