Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a way to browse packed resources inside .pck file #29655

Closed
hedin-hiervard opened this issue Jun 10, 2019 · 7 comments
Closed

Create a way to browse packed resources inside .pck file #29655

hedin-hiervard opened this issue Jun 10, 2019 · 7 comments

Comments

@hedin-hiervard
Copy link
Contributor

Godot version:
3.1

Issue description:

I have a directory called Levels with a bunch of json files I use as level templates. While developing I used Directory to iterate through them and load them. But when I export the project there is no (known to me) way to do this, so I end up with an empty list.

Steps to reproduce:

Minimal reproduction project:

@hedin-hiervard
Copy link
Contributor Author

https://docs.godotengine.org/en/3.1/getting_started/workflow/export/exporting_projects.html#export-mode

I read this and using this. Can you please elaborate a little bit on how can I iterate through resources in a directory inside a .pck file?

@Calinou
Copy link
Member

Calinou commented Jun 11, 2019

A workaround for now is to generate a text file containing a list of paths in a directory, and making sure it's exported using a non-resource export filter (like *.txt). This file can be generated in GDScript using an editor plugin, or using a shell or Batch script. These paths can then be read and used in other scripts.

@dalexeev
Copy link
Member

This does not negate the bug (non-obvious Directory behavior), but you can also try to make a non-resource file a resource:
https://docs.godotengine.org/en/3.1/tutorials/plugins/editor/import_plugins.html

@hedin-hiervard
Copy link
Contributor Author

Yes, I understand the possible workaround and is well aware of export options. I reported this because I believe Directory should behave more consistently.

@scottkunkel
Copy link

scottkunkel commented Jun 12, 2019

I cannot replicate:

extends Resource
class_name FileExt

static func list_files_in_directory(path, filter):
	var files = []
	var dir = Directory.new()
	dir.open(path)
	dir.list_dir_begin()

	while true:
		var file = dir.get_next()
		if file == "":
			break
		elif filter:
			if file.ends_with(filter):
				files.append(file)
		else:
			files.append(file)

	return files

calling with ("res://jsonfiles/", ".json") will list all json files correctly

You do have to make sure the files make it into the pck file:
image
or at least *.json

@Calinou
Copy link
Member

Calinou commented Jul 3, 2020

Duplicate of #25672.

@Calinou Calinou closed this as completed Jul 3, 2020
@Calinou Calinou added archived and removed bug labels Jul 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants