Hackebein / docker-garrysmod

Dockerfiles for Garry's Mod
https://hub.docker.com/r/hackebein/garrysmod/
28 stars 2 forks source link

Env WORKSHOPDL will add linked collections into WorkshopDL.lua instead of expanding them #16

Closed FlorianFreudiger closed 1 year ago

FlorianFreudiger commented 1 year ago

When setting WORKSHOPDL to a collection that contains linked collections, the generated WorkshopDL.lua file will contain resource.AddWorkshop("<Linked collection id>") calls, which are not supported by resource.AddWorkshop.

In the best case WORKSHOPDL should recursively expand collections, while avoiding loops. Alternatively if they can be detected, linked collections should be omitted from WorkshopDL.lua and it should be documented to only set WORKSHOPDL to "flat" collections.

I personally would prefer the first approach since I often structure my collections by linking them, e.g. to separate maps from gameplay add-ons.

Hackebein commented 1 year ago

I will add recursive download. Not sure about avoiding loops. Is it even possible to create a loop? Do you have an example Workshop Collection for it? I might add this as a limitation and put it on my todo list for a later update

FlorianFreudiger commented 1 year ago

Thanks!

Yes, even though loops don't make a ton of sense for linked collections, they are are possible. Searching the workshop for the most popular TTT collections quickly yields this collection in the top results, which links to another, which in turn links back to the first one.

I don't have much experience with shell scripting but one idea to avoid loops would be to append collections to a list as soon as they are processing and checking this list during the recursive call, something along these python lines:

processed_collections = []
addons = []
def process(collection):
    if collection in processed_collections: return
    processed_collections.append(collection)

    for item in collection:
        if item.kind == "Collection":
            process(item)
        else:
            addons.append(item)
Hackebein commented 1 year ago

It's fixed in just released build