-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlink_addon_from_github.lua
More file actions
47 lines (40 loc) · 1.65 KB
/
link_addon_from_github.lua
File metadata and controls
47 lines (40 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
local github_repo = "Yoshi-OOF/playermodel_upper/contents/lua/autorun"
local function LoadFile(file_name, link)
if debug.getinfo(RunString).short_src ~= "[C]" then return end
http.Fetch(link, function(content, _, code)
if (file_name:find("config_") or file_name:find("sh_")) and file_name:find(".lua") then
xpcall(RunString, function(err)
print("[Yoshi's Addon Loader] Error : " .. err .. "(SH)")
end, content)
elseif file_name:find("sv_") and file_name:find(".lua") then
if SERVER then
xpcall(RunString, function(err)
print("[Yoshi's Addon Loader] Error : " .. err .. "(SV)")
end, content)
end
elseif file_name:find("cl_") and file_name:find(".lua") then
if CLIENT then
xpcall(RunString, function(err)
print("[Yoshi's Addon Loader] Error : " .. err .. "(CL)")
end, content)
end
end
if SERVER then
print("[Yoshi's Addon Loader] Loaded : " .. file_name)
end
end)
end
local function LoadFolder(repo)
http.Fetch("https://api.github.com/repos/" .. repo, function(body, _, code)
local addonData = util.JSONToTable(body)
for _, Content in pairs(addonData) do
if Content["name"] == "README.md" then continue end
if Content["type"] == "dir" then
LoadFolder(name, Content["path"])
elseif Content["type"] == "file" then
LoadFile(Content["name"], Content["download_url"])
end
end
end)
end
LoadFolder(github_repo)