0 votes

The problematic function is shown below.

The problem strangely only happens after exporting, and when running from the editor everything is done perfectly and I can use the paths to randomly instance things.

I keep getting "Couldn't start file stream!" message which means it can't find the directory maybe? (Based on this from the docs)

The value for path is "res://episodes/3_end/". I also tried "/episodes/3_end/" but then it breaks everywhere.

func list_files_in_directory(path):
var paths = []
var dir = Directory.new()
    dmsg("\nCouldn't start file stream!\n")

while true:
    var file = dir.get_next()
    if file == "":
    elif (not file.begins_with(".") and file.extension() == "tscn"):
        paths.append(file.basename()+"." + file.extension())

return paths

Thank you all.

in Engine by (162 points)
edited by

Everything in res:// doesn't exist as files when you export a game, because they get bundled into the executable data, this is why it doesn't find the directory.
But that's just a guess, I used to use this to detect my levels in an early version of my game, I don't use it anymore so maybe something got broken in between...

Should work to load resources, but try exporting to zip and check the files in there (tscn are converted to "tscn.converted.scn", by the way)

Please log in or register to answer this question.

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.