-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdater.lua
63 lines (53 loc) · 2.32 KB
/
updater.lua
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
-----------------For support, scripts, and more----------------
--------------- https://discord.gg/wasabiscripts -------------
---------------------------------------------------------------
local curVersion = GetResourceMetadata(GetCurrentResourceName(), "version")
local resourceName = "koe_storageunitsv2"
if Config.checkForUpdates then
CreateThread(function()
if GetCurrentResourceName() ~= "koe_storageunitsv2" then
resourceName = "koe_storageunitsv2 (" .. GetCurrentResourceName() .. ")"
end
end)
CreateThread(function()
while true do
PerformHttpRequest("https://api.github.com/repos/dalkoe/koe_storageunitsv2/releases/latest", CheckVersion, "GET")
Wait(3600000)
end
end)
CheckVersion = function(err, responseText, headers)
local repoVersion, repoURL, repoBody = GetRepoInformations()
CreateThread(function()
if curVersion ~= repoVersion then
Wait(4000)
print("^0[^3WARNING^0] " .. resourceName .. " is ^1NOT ^0up to date!")
print("^0[^3WARNING^0] Your Version: ^2" .. curVersion .. "^0")
print("^0[^3WARNING^0] Latest Version: ^2" .. repoVersion .. "^0")
print("^0[^3WARNING^0] Get the latest Version from: ^2" .. repoURL .. "^0")
print("^0[^3WARNING^0] Changelog:^0")
print("^1" .. repoBody .. "^0")
else
Wait(4000)
print("^0[^2INFO^0] " .. resourceName .. " is up to date! (^2" .. curVersion .. "^0)")
end
end)
end
GetRepoInformations = function()
local repoVersion, repoURL, repoBody = nil, nil, nil
PerformHttpRequest("https://api.github.com/repos/dalkoe/koe_storageunitsv2/releases/latest", function(err, response, headers)
if err == 200 then
local data = json.decode(response)
repoVersion = data.tag_name
repoURL = data.html_url
repoBody = data.body
else
repoVersion = curVersion
repoURL = "https://github.com/dalkoe/koe_storageunitsv2"
end
end, "GET")
repeat
Wait(50)
until (repoVersion and repoURL and repoBody)
return repoVersion, repoURL, repoBody
end
end