Skip to content

Commit 9459d72

Browse files
committed
Rewrited to Yue
1 parent 6089dea commit 9459d72

7 files changed

Lines changed: 233 additions & 80 deletions

File tree

.github/workflows/yue_release.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Create Yuescript Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Change directory
16+
run: cd $GITHUB_WORKSPACE
17+
18+
- name: Remove unused files and folders
19+
run: |
20+
rm .gitignore
21+
rm -rf .github
22+
23+
- name: Create VERSION file
24+
run: echo -e ${{ github.ref_name }} > VERSION
25+
26+
- name: Download Yuescript and unzip yue
27+
run: |
28+
wget https://github.com/pigpigyyy/Yuescript/releases/download/v0.21.8/yue-linux-x86_64.zip
29+
unzip yue-linux-x86_64.zip
30+
rm yue-linux-x86_64.zip
31+
32+
- name: Build .lua and remove .yue
33+
run: |
34+
./yue ./
35+
rm yue
36+
find . -type f -name '*.yue' -delete
37+
38+
- name: Push to lua branch
39+
run: |
40+
git config user.name github-actions
41+
git config user.email github-actions@github.com
42+
git add .
43+
git commit -m "Release build: $(cat VERSION)"
44+
git push -f origin HEAD:lua
45+
46+
- name: Remove .git dir
47+
run: rm -rf .git
48+
49+
- name: Create subdirectory
50+
run: mkdir ${{ github.event.repository.name }}
51+
52+
- name: Move files into sub directory
53+
run: ls | grep -v ${{ github.event.repository.name }} | xargs mv -t ${{ github.event.repository.name }}
54+
55+
- name: Create Release Asset
56+
run: zip -r9 ${{ github.event.repository.name }}.zip .
57+
58+
- name: Publish Release
59+
uses: softprops/action-gh-release@v1
60+
id: create_release
61+
with:
62+
name: Release ${{ github.ref_name }}
63+
draft: false
64+
prerelease: false
65+
generate_release_notes: true
66+
files: |
67+
./${{ github.event.repository.name }}.zip

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.lua

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Pika Software
3+
Copyright (c) 2024 Pika Software
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Automatic Workshop DL
2-
No more workshop content management, just install me :)
2+
This addon automatically adds all active addons with content to WorkshopDL.
3+
In the case of maps, it will add the active map.
4+
Compatible with any game mode.
35

4-
## Description
5-
The addon automatically adds all active addons with content to the client download.
6-
In the case of maps it will add the active map.
7-
Compatible with any gamemode.
6+
## Where is Lua code?
7+
Written in [Yuescript](https://github.com/pigpigyyy/Yuescript), compiled Lua code can be found in [releases](https://github.com/Pika-Software/automatic-workshop-dl/releases) and [lua branch](https://github.com/Pika-Software/automatic-workshop-dl/tree/lua), or you can compile it yourself using compiled [Yuescript Compiler](https://github.com/pigpigyyy/Yuescript/releases/latest).
88

9-
## Package manager is required for the addon to work!
10-
[GLua Package Manager](https://github.com/Pika-Software/glua_package_manager)
9+
## ConVars
10+
- `awdl_ignore_maps` (def. 1) - If set to 1 will ignore any maps even if they contain content other than the current server map.

lua/packages/automatic-workshop-dl/init.lua

Lines changed: 0 additions & 66 deletions
This file was deleted.

lua/packages/automatic-workshop-dl/package.lua

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
if game.SinglePlayer!
2+
return
3+
4+
:lower, :Split, :StartsWith, :GetExtensionFromFilename = string
5+
:Exists, :Find = file
6+
resource = resource
7+
ipairs = ipairs
8+
9+
workshopDL = resource.WorkshopDL
10+
unless istable( workshopDL )
11+
workshopDL = {}
12+
resource.WorkshopDL = workshopDL
13+
14+
-- https://github.com/Facepunch/gmad/blob/master/include/AddonWhiteList.h
15+
resourceExtensions = {
16+
-- Models
17+
"mdl": true
18+
"vtx": true
19+
"phy": true
20+
"ani": true
21+
"vvd": true
22+
23+
-- Sounds
24+
"wav": true
25+
"mp3": true
26+
"ogg": true
27+
28+
-- Materials & Textures
29+
"vmt": true
30+
"vtf": true
31+
"png": true
32+
"jpg": true
33+
"jpeg": true
34+
"raw": true
35+
36+
-- Fonts
37+
"ttf": true
38+
39+
-- Animations
40+
"ani": true
41+
42+
-- Particles
43+
"pcf": true
44+
45+
-- Scenes
46+
"vcd": true
47+
48+
-- Localization
49+
"properties": true
50+
}
51+
52+
getTag = nil
53+
do
54+
55+
tagNames = {
56+
"gamemode": "Gamemode"
57+
"map": "Map"
58+
"weapon": "Weapon"
59+
"vehicle": "Vehicle"
60+
"npc": "NPC"
61+
"entity": "Entity"
62+
"tool": "Tool"
63+
"effects": "Effect"
64+
"model": "Model"
65+
"servercontent": "Server Content"
66+
}
67+
68+
getTag = ( addon ) ->
69+
for _, tag in ipairs( Split( addon.tags, "," ) )
70+
tag = tagNames[ lower( tag ) ]
71+
if tag ~= nil
72+
return tag
73+
74+
return "Addon"
75+
76+
addCWorkshop = resource.AddCWorkshop
77+
unless addCWorkshop
78+
addCWorkshop = resource.AddWorkshop
79+
resource.AddCWorkshop = addCWorkshop
80+
81+
addons = engine.GetAddons!
82+
addonsCount = #addons
83+
84+
addWorkshop = nil
85+
do
86+
87+
MsgC = MsgC
88+
89+
color0 = Color( 200, 200, 200 )
90+
color1 = Color( 180, 180, 180 )
91+
color2 = Color( 20, 150, 240 )
92+
93+
addWorkshop = ( wsid ) ->
94+
if workshopDL[ wsid ]
95+
return
96+
97+
workshopDL[ wsid ] = true
98+
addCWorkshop( wsid )
99+
workshopDL[] = wsid
100+
101+
for index = 1, addonsCount
102+
if addons[ index ].wsid == wsid
103+
MsgC( color1, "[", color2, "WorkshopDL", color1, "] + ", color0, getTag( addons[ index ] ) .. ": ", color2, addons[ index ].title, color1, " ( ", color0, wsid, color1, " )\n" )
104+
return
105+
106+
MsgC( color1, "[", color2, "WorkshopDL", color1, "] + ", color0, "Addon: ", color2, "unknown", color1, " ( ", color0, wsid, color1, " )\n" )
107+
108+
resource.AddWorkshop = addWorkshop
109+
110+
scanAddon = ( gamePath, folderPath, result, length ) ->
111+
if folderPath == nil
112+
result, length = {}, 0
113+
114+
files, folders = Find( "*", gamePath )
115+
for _, fileName in ipairs( files )
116+
length += 1
117+
result[ length ] = fileName
118+
119+
for _, folderName in ipairs( folders )
120+
scanAddon( gamePath, folderName, result, length )
121+
122+
return result
123+
124+
files, folders = Find( folderPath .. "/*", gamePath )
125+
for _, fileName in ipairs( files )
126+
length += 1
127+
result[ length ] = folderPath .. "/" .. fileName
128+
129+
for _, folderName in ipairs( folders )
130+
scanAddon( gamePath, folderPath .. "/" .. folderName, result, length )
131+
132+
return result
133+
134+
ignoreOtherMaps = CreateConVar( "awdl_ignore_maps", "1", bit.bor( FCVAR_ARCHIVE, FCVAR_DONTRECORD, FCVAR_NOTIFY ), "If enabled, WorkshopDL will ignore all maps except the current map." )
135+
mapName = game.GetMap!
136+
137+
for i = 1, addonsCount
138+
addon = addons[ i ]
139+
unless addon.downloaded and addon.mounted
140+
continue
141+
142+
if mapName ~= nil and Exists( "maps/" .. mapName .. ".bsp", addon.title )
143+
addWorkshop( addon.wsid )
144+
mapName = nil
145+
continue
146+
147+
if ignoreOtherMaps\GetBool! and getTag( addon ) == "Map"
148+
continue
149+
150+
if addon.models > 0
151+
addWorkshop( addon.wsid )
152+
continue
153+
154+
for _, filePath in ipairs( scanAddon( addon.title ) )
155+
if StartsWith( filePath, "data_static/" ) or resourceExtensions[ GetExtensionFromFilename( filePath ) ]
156+
addWorkshop( addon.wsid )
157+
break

0 commit comments

Comments
 (0)