View difference between Paste ID: 5ZN3mfH1 and wJCujUs2
SHOW: | | - or go back to the newest paste.
1
-- Advanced Updater by Henness
2
-- Version 1.1 1/13/2014
3
4
-- Config
5
local author = "Henness0666"
6
local project = "Advanced-Programs"
7
local branch = "master"
8
local screenw,screenh = term.getSize()
9
10
-- Functions
11
function printIntro()
12
	local intro = {
13
		[1]  = {" "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","d","8","8","8","8"," "," "," "," "," "," ","8","8","8"," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","8","8","8"," "," "," "," "," "," ","8","8","8","8","8","8","8","b","."," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "},
14
		[2]  = {" "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","d","8","8","8","8","8"," "," "," "," "," "," ","8","8","8"," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","8","8","8"," "," "," "," "," "," ","8","8","8"," "," "," ","Y","8","8","b"," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "},
15
		[3]  = {" "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","d","8","8","P","8","8","8"," "," "," "," "," "," ","8","8","8"," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","8","8","8"," "," "," "," "," "," ","8","8","8"," "," "," "," ","8","8","8"," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "},
16
		[4]  = {" "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","d","8","8","P"," ","8","8","8"," "," ",".","d","8","8","8","8","8"," ","8","8","8"," "," ","8","8","8"," "," ","8","8","8","8","b","."," "," ","8","8","8","8","8","b","."," "," "," ",".","d","8","8","8","8","b"," ",".","d","8","8","b","."," "," "," ",".","d","8","8","8","8","8"," "," "," "," "," "," ","8","8","8"," "," "," ","d","8","8","P"," ","8","8","8","d","8","8","8"," ",".","d","8","8","b","."," "," "," ",".","d","8","8","b","."," "," ","8","8","8","d","8","8","8"," ","8","8","8","8","b","."," "," ","8","8","8","8","8","b",".","d","8","8","b","."," "," ",".","d","8","8","8","8","b"," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "},
17
		[5]  = {" "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","d","8","8","P"," "," ","8","8","8"," ","d","8","8","\""," ","8","8","8"," ","8","8","8"," "," ","8","8","8"," "," "," "," "," ","\"","8","8","b"," ","8","8","8"," ","\"","8","8","b"," ","d","8","8","P","\""," "," "," ","d","8","P"," "," ","Y","8","b"," ","d","8","8","\""," ","8","8","8"," "," "," "," "," "," ","8","8","8","8","8","8","8","P","\""," "," ","8","8","8","P","\""," "," ","d","8","8","\"","\"","8","8","b"," ","d","8","8","P","\"","8","8","b"," ","8","8","8","P","\""," "," "," "," "," "," ","\"","8","8","b"," ","8","8","8"," ","\"","8","8","8"," ","\"","8","8","b"," ","8","8","K"," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "},
18
		[6]  = {" "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","d","8","8","P"," "," "," ","8","8","8"," ","8","8","8"," "," ","8","8","8"," ","Y","8","8"," "," ","8","8","P"," ",".","d","8","8","8","8","8","8"," ","8","8","8"," "," ","8","8","8"," ","8","8","8"," "," "," "," "," ","8","8","8","8","8","8","8","8"," ","8","8","8"," "," ","8","8","8"," "," "," "," "," "," ","8","8","8"," "," "," "," "," "," "," "," ","8","8","8"," "," "," "," ","8","8","8"," "," ","8","8","8"," ","8","8","8"," "," ","8","8","8"," ","8","8","8"," "," "," "," ",".","d","8","8","8","8","8","8"," ","8","8","8"," "," ","8","8","8"," "," ","8","8","8"," ","\"","Y","8","8","8","8","b","."," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "},
19
		[7]  = {" "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","d","8","8","8","8","8","8","8","8","8","8"," ","Y","8","8","b"," ","8","8","8"," "," ","Y","8","b","d","8","P"," "," ","8","8","8"," "," ","8","8","8"," ","8","8","8"," "," ","8","8","8"," ","Y","8","8","b","."," "," "," ","Y","8","b","."," "," "," "," "," ","Y","8","8","b"," ","8","8","8"," "," "," "," "," "," ","8","8","8"," "," "," "," "," "," "," "," ","8","8","8"," "," "," "," ","Y","8","8",".",".","8","8","P"," ","Y","8","8","b"," ","8","8","8"," ","8","8","8"," "," "," "," ","8","8","8"," "," ","8","8","8"," ","8","8","8"," "," ","8","8","8"," "," ","8","8","8"," "," "," "," "," "," ","X","8","8"," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "},
20
		[8]  = {" "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","d","8","8","P"," "," "," "," "," ","8","8","8"," "," ","\"","Y","8","8","8","8","8"," "," "," ","Y","8","8","P"," "," "," ","\"","Y","8","8","8","8","8","8"," ","8","8","8"," "," ","8","8","8"," "," ","\"","Y","8","8","8","8","P"," ","\"","Y","8","8","8","8"," "," "," ","\"","Y","8","8","8","8","8"," "," "," "," "," "," ","8","8","8"," "," "," "," "," "," "," "," ","8","8","8"," "," "," "," "," ","\"","Y","8","8","P","\""," "," "," ","\"","Y","8","8","8","8","8"," ","8","8","8"," "," "," "," ","\"","Y","8","8","8","8","8","8"," ","8","8","8"," "," ","8","8","8"," "," ","8","8","8"," "," ","8","8","8","8","8","P","'"," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "},
21
		[9]  = {" "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","8","8","8"," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "},
22
		[10] = {" "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","Y","8","b"," ","d","8","8","P"," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "},
23
		[11] = {" "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","\"","Y","8","8","P","\""," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "}
24
	}
25
	local str = "[PRESS ANY KEY TO SKIP]"
26
	term.clear()
27
	for i=1,#intro[1]-screenw do
28
		term.setCursorPos(1, 1)
29
		write(string.rep("-", screenw))
30
		term.setCursorPos(1, screenh)
31
		write(string.rep("-", (screenw/2)-(#str/2))..str..string.rep("-", (screenw/2)-(#str/2)))
32
		sleep(0.001)
33
		for key,value in pairs(intro) do
34
			for xpos=1,screenw do
35
				term.setCursorPos(xpos, (screenh-11)/2+key)
36
				write(intro[key][xpos+i-1])
37
			end
38
		end
39
	end
40
end
41
42
function skip()
43
	local id, key = os.pullEvent("key")
44
end
45
46
function loadTable(name)
47
	local file = fs.open(name,"r")
48
	local data = file.readAll()
49
	file.close()
50
	return textutils.unserialize(data)
51
end
52
53
function saveTable(table,name)
54
	local file = fs.open(name,"w")
55
	file.write(textutils.serialize(table))
56
	file.close()
57
end
58
59
function getLink(file)
60
	return "https://raw.github.com/" .. author .. "/" .. project .. "/" .. branch .. "/" .. file
61
end
62
63
function download(file, name)
64
	print("Downloading, " .. file)
65
	local data = http.get(getLink(file))
66
	if data then
67
		print(file .. " downloaded")
68
		local file = fs.open(name,"w")
69
		file.write(data.readAll())
70
		file.close()
71
		return true
72
	end
73
end
74
75
function updatePrograms()
76
	term.clear()
77
	term.setCursorPos(1,1)
78
	print("Checking for Updates...")
79
	if fs.exists("apconfig") then
80
		if download("config", "tmpconfig") then
81
			config = loadTable("apconfig")
82
			tmpconfig = loadTable("tmpconfig")
83
			for key,value in pairs(tmpconfig) do
84
				if tmpconfig[key]["version"] > config[key]["version"] then
85
					if fs.exists(key) then
86
						fs.delete(key)
87
					end
88
					download(key, tmpconfig[key]["path"])
89
				end
90
			end
91
			fs.delete("apconfig")
92
			saveTable(tmpconfig, "apconfig")
93
			fs.delete("tmpconfig")
94
		else
95
			print("Unable to connect to http://github.com/")
96
		end
97
	else
98
		print("No config file was found.")
99
		if download("config", "apconfig") then
100
			config = loadTable("apconfig")
101
			for key,value in pairs(config) do
102
				if fs.exists(key) then
103
					fs.delete(key)
104
				end
105
				download(key, config[key]["path"])
106
			end
107
		else
108
			print("Unable to connect to http://github.com/")
109
		end
110
	end
111
	print("All programs updated.")
112
	print("Press any key to continue.")
113
	skip()
114
end
115
116
-- RUN
117
parallel.waitForAny(printIntro, skip)
118
updatePrograms()
119
if fs.exists("advancedgui")then
120
	shell.run("advancedgui")
121
end