-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdateButtonAPI.lua
More file actions
45 lines (36 loc) · 1.02 KB
/
updateButtonAPI.lua
File metadata and controls
45 lines (36 loc) · 1.02 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
function downloadAPI()
print("Updating...")
request = http.get("https://raw.github.com/Morgrimm/CCButtonAPI/master/CCButtonAPI.txt")
data = request.readAll()
if fs.exists("button") then
fs.delete("button")
file = fs.open("button", "w")
file.write(data)
file.close()
else
file = fs.open("button", "w")
file.write(data)
file.close()
end
print("Update complete.")
end
if fs.exists("button") then
os.unloadAPI("button")
os.loadAPI("button")
clientVersion = button.version()
versionRequest = http.get("https://raw.github.com/Morgrimm/CCButtonAPI/master/CCButtonAPI.versions.txt")
serverVersion = versionRequest.readAll()
if serverVersion == clientVersion then
print("You have the newest version of the API.")
else
print("Version "..serverVersion.." is now available. Would you like to update?")
input = read()
if string.lower(input) == "yes" then
downloadAPI()
else
print("Update canceled.")
end
end
else
downloadAPI()
end