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()
dir.open(path)
if(dir.list_dir_begin()):
    dmsg("\nCouldn't start file stream!\n")

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

dir.list_dir_end()
return paths

Thank you all.

asked May 13, 2017 in Engine by M. Alkotob (162 points)
edited May 13, 2017 by M. Alkotob

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.