Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local githubPath = "https://raw.githubusercontent.com/CodingButter/beastcraft/main"
- local files = {
- beastcraft = {
- core = {"class.lua", "shape.lua", "utils.lua", "workloop.lua"},
- dom = {
- elements = {"body.lua", "button.lua", "div.lua", "element.lua", "init.lua", "input.lua", "ul.lua"},
- "init.lua",
- "selector.lua",
- "style.lua"
- },
- managers = {"listeners.lua", "state.lua"},
- ui = {"domrenderer.lua", "init.lua"},
- "init.lua"
- },
- src = {
- components = {"button.lua", "menu.lua","input.lua"},
- context = {"menucontext.lua"},
- "app.lua"
- },
- "startup.lua",
- "main.lua"
- }
- local totalFiles = 0
- local downloaded = 0
- local function calculateFiles(_tbl)
- for k, v in pairs(_tbl) do
- if type(v) == "table" then
- calculateFiles(v)
- else
- totalFiles = totalFiles + 1
- end
- end
- end
- local fileColors = {
- colors.white,
- colors.lightGray,
- colors.gray
- }
- local fileNames = {}
- local function downloadFiles(_tbl, dir)
- local WIDTH,HEIGHT = term.getSize()
- for k, v in pairs(_tbl) do
- if type(v) == "table" then
- downloadFiles(v, dir .. "/" .. k)
- else
- local path = dir .. "/" .. v
- shell.run("wget", githubPath .. path, "/disk/"..path)
- table.insert(fileNames,1,path)
- downloaded = downloaded + 1
- term.clear()
- term.setTextColor(colors.white)
- local installText = "--[[ Installing BeastCraft ]]--"
- local progressText = downloaded .. " of " .. totalFiles .. "(" .. math.ceil(100 * (downloaded / totalFiles)) .. "%)"
- term.setCursorPos(WIDTH/2-#installText/2,2)
- term.write(installText)
- term.setCursorPos(WIDTH/2-#progressText/2,3)
- term.write(progressText)
- for i=1,3 do
- if fileNames[i] then
- term.setCursorPos(WIDTH/2-#fileNames[i]/2,i+3)
- term.setTextColor(fileColors[i])
- term.write(fileNames[i])
- end
- end
- end
- end
- term.setCursorPos(WIDTH/2-3,7)
- end
- calculateFiles(files)
- downloadFiles(files, "")
- shell.run("/disk/main")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement