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

feat: Add workshop GetAddonContributions function #31

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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