-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweeklies.mod.gml
75 lines (69 loc) · 3.25 KB
/
weeklies.mod.gml
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
var _name = "weeklies";
var _repo = "GoldenEpsilon/NTT-Modded-Weeklies";
global.forks = 0;
cansideload = 1;
while(!mod_sideload()){wait 1;}
trace_color("Downloading Modded Weeklies!", c_purple);
file_delete(_name+"branches.json");
while (file_exists(_name+"branches.json")) {wait 1;}
wait file_unload(_name+"branches.json");
trace_color("Downloading branches...", c_purple);
wait file_download("https://api.github.com/repos/" + _repo + "/branches", _name+"branches.json");
trace_color("Branches downloaded...", c_purple);
file_load(_name+"branches.json");
while (!file_loaded(_name+"branches.json")) {wait 1;}
while (!file_exists(_name+"branches.json")) {wait 1;}
var branches = json_decode(string_load(_name+"branches.json"));
wait file_unload(_name+"branches.json");
if(branches != json_error){
if(is_array(branches)){
file_delete(_name+"tree.json");
while (file_exists(_name+"tree.json")) {wait 1;}
wait file_unload(_name+"tree.json");
trace_color("Downloading commit data...", c_purple);
wait file_download("https://api.github.com/repos/" + _repo + "/git/trees/"+branches[0].commit.sha+"?recursive=1", _name+"tree.json");
file_load(_name+"tree.json");
trace_color("Commit data downloaded...", c_purple);
while (!file_loaded(_name+"tree.json")) {wait 1;}
while (!file_exists(_name+"tree.json")) {wait 1;}
var tree = json_decode(string_load(_name+"tree.json"));
wait file_unload(_name+"tree.json");
if(tree != json_error){
with(tree.tree){
if(type == "blob" && string_count("mod/", path) && fork()){
var newpath = string_replace(path, "mod/", "")
global.forks++;
//Replace a file
file_delete("../../mods/" + _name + "/" + newpath);
while (file_exists("../../mods/" + _name + "/" + newpath)) {wait 1;}
wait file_download("https://raw.githubusercontent.com/" + _repo + "/" + branches[0].name + "/" + path, "../../mods/" + _name + "/" + newpath);
while (!file_exists("../../mods/" + _name + "/" + newpath)) {wait 1;}
global.forks--;
exit;
}
}
wait(0);
var forks = global.forks;
while(global.forks > 0){
trace_color("Update for "+_name+" is "+string(round((1-(global.forks/forks))*100))+"% done.", c_purple);
wait(30);
}
}else{
//set it to download again when it can
file_delete(_name+"tree.json");
trace_color("ERROR. Were you downloading too much at once?", c_purple);
}
if("message" in tree){
trace_color(tree.message, c_purple);
}
}else{
//set it to download again when it can
file_delete(_name+"branches.json");
trace_color("ERROR. Were you downloading too much at once?", c_purple);
}
}
trace_color(_name + " download complete!", c_purple);
string_save("/load main.txt", "../../mods/" + _name + "/" + "reload.txt");
wait file_load("../../mods/" + _name + "/" + "reload.txt");
while !file_exists("../../mods/" + _name + "/" + "reload.txt") wait(0)
mod_loadtext(_name + "/" + "reload.txt");