Skip to content

Conversation

koerismo
Copy link
Member

Adds a function to list the files currently being provided by a given addon.

const files = WorkshopAPI.GetAddonContributions(myAddonID);
// files = [
// "models/my_addon/test_model.mdl",
// "models/my_addon/test_model.vtx",
// "models/my_addon/test_model.vvd" ]

@koerismo koerismo added the Proposal Proposing a new feature or enhancement. label Dec 22, 2024
@koerismo koerismo requested a review from JJL772 December 22, 2024 04:41
@JJL772
Copy link
Member

JJL772 commented Dec 22, 2024

I'd rather have something like this:

const types = WorkshopAPI.GetAddonContributions(myAddonID);
// types = ["sounds", "models", "materials", "maps", "scripts", "panorama"]

Returning a full file listing from the addon would be extremely expensive both in terms of disk I/O and memory usage (because we'd need to store that file listing in memory).

We could instead do some basic indexing like this:

for f in "sound/*"; do
  if isfile(f):
    types.append("sounds")
    break
... (repeat for models, materials, etc.) ...

which would be reasonably fast, especially for packed addons. We cannot rely on the addons to self-report anything in their metadata either.

@koerismo
Copy link
Member Author

That's fine, we just need some way to know what an addon contributes without relying on author-provided info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Proposal Proposing a new feature or enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants