Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- local programs = {"setup", "packyourstuff", "exm", "exf", "exfm", "goTo", "getlavaplus", "getlava", "aTreeFarm", "tfl"}
- local codes = {"WJydmc9x", "tf0gVZsZ", "0sAmVV2y", "7kt8vN9V", "uRqQmzdZ", "VsCyYRjN", "k1bggX4i", "nFSUKiYE", "JgRgRK5q", "PrHNL39i"}
- local list = {}
- for i=1, #programs do
- list[programs[i]] = codes[i]
- end
- list["update"] = "5bsg0h5G"
- local total = 1
- local succ = 0
- local fail = 0
- local fail_list = {}
- if tArgs[1] == nil then
- term.clear()
- term.setCursorPos(1, 1)
- print("What would you like to install?")
- for i = 1, #programs do
- print("> " .. programs[i])
- end
- print("> (all)")
- tArgs[1] = read()
- end
- if tArgs[1] == "all" then
- total = "all"
- end
- local function update()
- http.request("http://pastebin.com/raw.php?i=5bsg0h5G")
- requesting = true
- while requesting do
- local event, url, sourceText = os.pullEvent()
- if event == "http_success" then
- respondedText = sourceText.readAll()
- fs.delete("update.lua")
- file = fs.open("update.lua", "w")
- file.write(respondedText)
- file.close()
- requesting = false
- else
- requesting = false
- end
- end
- end
- local function request(_name)
- success = 0
- local c = list[_name]
- http.request("https://pastebin.com/raw/" .. c)
- requesting = true
- while requesting do
- local event, url, sourceText = os.pullEvent()
- if event == "http_success" then
- respondedText = sourceText.readAll()
- if respondedText ~= "" then
- fs.delete(_name..".lua")
- file = fs.open(_name..".lua", "w")
- file.write(respondedText)
- file.close()
- succ = succ + 1
- success = 1
- else
- success = 2
- end
- requesting = false
- else
- success = 3
- fail = fail +1
- fail_list[fail] = _name
- requesting = false
- end
- end
- return success
- end
- local function contains(_table, _val)
- for i = 1, #_table do
- if _table[i] == _val then
- return true
- end
- end
- return false
- end
- local function index(_table, _val)
- for i = 1, #_table do
- if _table[i] == _val then
- return i
- end
- end
- return 0
- end
- -----[ start ]-----
- if tArgs[1] == "update" then
- sleep(1)
- update()
- sleep(1)
- else
- term.clear()
- term.setCursorPos(15, 1)
- term.write("Installing...")
- sleep(1)
- update()
- sleep(1)
- if total == 1 then
- local tsucc = 0
- term.setCursorPos(2, 3)
- term.write("Installing [" .. tArgs[1] .."]...")
- if contains(programs, tArgs[1]) then
- tsucc = request(tArgs[1])
- end
- if tsucc == 1 then
- term.write(" Success!")
- elseif tsucc == 0 then
- term.write(" Skipped!")
- elseif tsucc == 2 then
- term.write(" Invalid!")
- elseif tsucc == 3 then
- term.write(" Failed!")
- end
- term.setCursorPos(1, 4)
- else
- if total == "all" then
- total = #programs
- for i = 1, #programs do
- term.setCursorPos(1, 3)
- term.clearLine()
- term.setCursorPos(2, 3)
- term.write("[" .. programs[i] .."]...")
- term.setCursorPos(33, 3)
- term.write("(" .. i .. "/" .. total .. ")")
- term.setCursorPos(16, 3)
- local success = request(programs[i])
- if tsucc == 1 then
- term.write(" Success!")
- elseif tsucc == 0 then
- term.write(" Skipped!")
- elseif tsucc == 2 then
- term.write(" Invalid!")
- elseif tsucc == 3 then
- term.write(" Failed!")
- end
- end
- term.setCursorPos(12, 1)
- term.write("Installing Done!")
- term.setCursorPos(2, 4)
- term.clearLine()
- term.write("Installed (" .. succ .. "/" .. total .. ") successfully!")
- term.setCursorPos(1, 5)
- if fail > 0 then
- term.setCursorPos(2, 6)
- term.clearLine()
- term.write("Failed [" .. fail .. "]:")
- term.setCursorPos(1, 7)
- if fail < 6 then
- for f=1, #fail_list do
- term.setCursorPos(2, f + 7)
- term.clearLine()
- term.write("> " .. fail_list[f])
- end
- else
- for f=1, 4 do
- term.setCursorPos(2, f + 7)
- term.clearLine()
- term.write("> " .. fail_list[f])
- end
- term.setCursorPos(2, 12)
- term.clearLine()
- term.write("> [" .. (fail-4) .. "] more...")
- end
- term.setCursorPos(1, 13)
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment