Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mode = (select(1, ...) or "--client"):sub(3)
- local function color(...)
- for i, arg in ipairs({...}) do
- if type(arg) == "number" then
- term.setTextColor(arg)
- else
- write(arg)
- end
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- color(colors.yellow, "SoLMISS Installer\n")
- if mode ~= "client" and mode ~= "server" then
- printError("invalid mode '"..mode.."'; must be 'client' or 'server'")
- return
- end
- color(colors.white, "Running in ", colors.lightBlue, mode, colors.white, " mode\n")
- local url = "https://raw.githubusercontent.com/ocawesome101/solmiss/primary/"
- local function dl(f)
- local hand, err = http.get(url..f, nil, true)
- if not hand then
- return
- end
- local data = hand.readAll()
- hand.close()
- return data
- end
- color(colors.white, "Downloading files... ")
- local common = dl("solmiss/common.lua")
- local special = dl(mode == 'server' and "server.lua" or "client.lua")
- if not (common and special) then
- printError("failed")
- return
- end
- color(colors.lime, "success\n")
- fs.makeDir("/solmiss")
- io.open("/solmiss/common.lua", "w"):write(common):close()
- io.open("/startup.lua", "w"):write(special):close()
- local function at(x, y, c)
- term.setCursorPos(x, y)
- term.setTextColor(c)
- return term
- end
- local function progress(y, a, b)
- local progress = a/100
- if b then progress = a/b end
- local w = term.getSize()
- at(1, y, colors.yellow).write("[")
- at(2, y, colors.white).write(("#"):rep(math.ceil(progress * (w - 2))))
- at(w, y, colors.yellow).write("]")
- term.setTextColor(colors.white)
- end
- color(colors.white, "Done. Restarting into setup screen.\n")
- local finish = os.epoch("utc") + 3000
- local _, y = term.getCursorPos()
- while os.epoch("utc") < finish do
- sleep(0)
- progress(y, os.epoch("utc") - finish + 3000, 3000)
- end
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement