Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- CONSTANTS
- local BASE_URL = "https://raw.githubusercontent.com/Qivex/qua/master/"
- local BASE_PATH = "apis/qua"
- local FILES = {
- "/init",
- "/cc/init",
- "/cc/color",
- "/cc/side",
- "/core/init",
- "/core/assert",
- "/core/class",
- "/core/config",
- "/ui/init",
- "/ui/animation",
- "/ui/box",
- "/ui/button",
- "/ui/clickable",
- "/ui/display",
- "/ui/drawable",
- "/ui/image",
- "/ui/label",
- "/ui/markup",
- "/ui/multiscreen",
- "/ui/screen",
- "/ui/window",
- "/tools/init",
- "/tools/array",
- "/tools/rsqueue",
- "/tools/shortcuts"
- }
- -- IMPLEMENTATION
- local x,y = term.getCursorPos()
- local log = function(text)
- term.clearLine()
- term.setCursorPos(x,y)
- term.write(text)
- end
- fs.delete(BASE_PATH)
- for index, file in pairs(FILES) do
- local url = BASE_URL .. file .. ".lua"
- local path = BASE_PATH .. file
- local dir = path:match("^(.*)/.-$")
- if not fs.isDir(dir) then
- fs.makeDir(dir)
- end
- if fs.exists(path) then
- fs.delete(path)
- end
- log("Downloading '" .. file .. "' (" .. index .. " of " .. #FILES .. ")")
- http.request(url)
- local event, url, response = os.pullEvent()
- if event == "http_success" then
- local content = response.readAll()
- response.close()
- local file = fs.open(path, "w")
- file.write(content)
- file.close()
- else
- error("Failure: Not found or interrupted - try again.")
- end
- end
- log("")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement