Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- In progress.
- Will be a sort of easy pastebin updater thing once I'm done
- not really much to it
- ]]
- --[[
- local filesToGet = {
- {
- name = "startup",
- loc = "blabla",
- }
- }
- ]]
- local filesToGet = dofile("filesToGet")
- local nFiles = #filesToGet
- local sFiles = tostring(#filesToGet)
- local function PE(i,err)
- local oldC = term.getTextColor()
- term.setTextColor(colors.red)
- print("Failed to download "..filesToGet[i].name.." due to: "..err)
- term.setTextColor(oldC)
- end
- print("Deleting required files...")
- for i = 1,nFiles do
- print("Deleting "..filesToGet[i].name.."...")
- fs.delete(filesToGet[i].name)
- end
- print("Done.")
- print("Deleted "..sFiles.." files.")
- print("Attempting to download "..sFiles.." files.")
- for i = 1,nFiles do
- print()
- print("Attempting to download file from Pastebin: " .. filesToGet[i].name)
- print("Connecting to Pastebin...")
- local h1 = http.get("https://pastebin.com/raw/" .. textutils.urlEncode(filesToGet[i].loc) .. "?cb=" .. tostring(math.random(0, 2^30)))
- if h1 then
- print("Connected!")
- print("Opening file: "..filesToGet[i].name)
- local h2 = fs.open(filesToGet[i].name,"w")
- if h2 then
- print("File successfully opened!")
- h2.write(h1.readAll())
- h2.close()
- print("Download success!")
- else
- PE(i,"Failed to open file.")
- end
- h1.close()
- else
- PE(i,"Failed to connect to pastebin.")
- end
- end
Add Comment
Please, Sign In to add comment