-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathUpdate.lua
More file actions
37 lines (30 loc) · 1.06 KB
/
Copy pathUpdate.lua
File metadata and controls
37 lines (30 loc) · 1.06 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
-- Update script
-- Automatically downloads ComputerCraft programs to a computer
urls = {
{"Button", "https://raw.githubusercontent.com/Jiggins/ComputerCraft/master/Button.lua"},
{"MiningTurtle", "https://raw.githubusercontent.com/Jiggins/ComputerCraft/master/MiningTurtle.lua"},
{"EventListener", "https://raw.githubusercontent.com/Jiggins/ComputerCraft/master/EventListener.lua"},
{"ReactorControl", "https://raw.githubusercontent.com/Jiggins/ComputerCraft/master/ReactorControl.lua"},
{"update", "https://raw.githubusercontent.com/Jiggins/ComputerCraft/master/Update.lua"}
}
function download(name, url)
print("Updating " .. name)
request = http.get(url)
data = request.readAll()
if fs.exists(name) then
fs.delete(name)
file = fs.open(name, "w")
file.write(data)
file.close()
else
file = fs.open(name, "w")
file.write(data)
file.close()
end
print("Successfully downloaded " .. name .. "\n")
end
for key, value in ipairs(urls) do
download(unpack(value))
end
term.clear()
term.setCursorPos()