-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
111 lines (102 loc) · 3.46 KB
/
Copy pathinit.lua
File metadata and controls
111 lines (102 loc) · 3.46 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
--!nocheck
local license = ... or {}
local cloneref = cloneref or function(ref) return ref end
local isfile = isfile or function(file)
local suc, res = pcall(function()
return readfile(file)
end)
return suc and res ~= nil and res ~= ''
end
local delfile = delfile or function(file)
writefile(file, '')
end
local downloader = Instance.new('TextLabel')
downloader.Size = UDim2.new(1, 0, 0, 40)
downloader.BackgroundTransparency = 1
downloader.TextStrokeTransparency = 0
downloader.TextSize = 20
downloader.TextColor3 = Color3.new(1, 1, 1)
downloader.Font = Enum.Font.Arial
downloader.Text = ''
downloader.Visible = not (license and license.Closet)
downloader.Parent = Instance.new('ScreenGui', gethui and gethui() or cloneref(game:GetService('CoreGui')))
local function downloadFile(path, func)
if not isfile(path) then
if not license.Closet then
downloader.Text = 'Downloading '.. path
end
local suc, res = pcall(function()
return game:HttpGet('https://raw.githubusercontent.com/minikids/kitv4/'..readfile('KitVape/profiles/commit.txt')..'/'..select(1, path:gsub('KitVape/', '')), true)
end)
if not suc or res == '404: Not Found' then
error(res)
end
if path:find('.lua') then
res = '--This watermark is used to delete the file if its cached, remove it to make the file persist after kitv4 updates.\n'..res
end
writefile(path, res)
downloader.Text = ''
end
return (func or readfile)(path)
end
local function wipeFolder(path)
if not isfolder(path) then return end
for _, file in listfiles(path) do
if file:find('init') then continue end
if file:find('profile') then continue end
if isfile(file) then
delfile(file)
elseif isfolder(file) then
wipeFolder(file)
end
end
end
for _, folder in {'KitVape', 'KitVape/games', 'KitVape/profiles', 'KitVape/assets', 'KitVape/libraries', 'KitVape/guis'} do
if not isfolder(folder) then
if not (license and license.Closet) then
downloader.Text = 'Downloading '.. folder
end
makefolder(folder)
end
end
if not shared.VapeDeveloper then
local commit = license.Commit or nil
if not commit then
local _, subbed = pcall(function()
return game:HttpGet('https://github.com/minikids/kitv4')
end)
commit = subbed:find('currentOid')
commit = commit and subbed:sub(commit + 13, commit + 52) or nil
commit = commit and #commit == 40 and commit or 'main'
end
-- Only wipe when transitioning between two non-'main' commits.
-- When commit is 'main' (the default loadstring), trust whatever
-- is on disk so local module edits are preserved across reloads.
local cached_commit = (isfile('KitVape/profiles/commit.txt') and readfile('KitVape/profiles/commit.txt') or '')
if commit ~= 'main' and cached_commit ~= '' and cached_commit ~= commit then
shared.updated = cached_commit
wipeFolder('KitVape')
wipeFolder('KitVape/games')
wipeFolder('KitVape/guis')
wipeFolder('KitVape/libraries')
end
writefile('KitVape/profiles/commit.txt', commit)
if #listfiles('KitVape/profiles') < 4 then
local req = request({
Url = 'https://api.github.com/repos/minikids/kitv4/contents/profiles',
Method = 'GET'
})
if req.StatusCode == 200 then
local body = cloneref(game:GetService('HttpService')):JSONDecode(req.Body)
if body and typeof(body) == 'table' then
for _, v in body do
if v.type == 'file' then
pcall(downloadFile, 'KitVape/'.. ({v.path:gsub(' ', '%%20')})[1])
end
end
end
end
end
end
downloader.Text = ''
return loadstring(downloadFile('KitVape/main.lua'), 'main')(license)