Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- mcCTKyRS
- function Main()
- local progs = require("pastes")
- -- remove deleted scripts from pastebinScripts before we update existing
- -- ones; whithout this, deleted scripts would reappear on update
- settings.load()
- local deletedScripts = {}
- local existingPasteScripts = {}
- for _,pasteScript in pairs(settings.get("PastebinScripts",{})) do
- if fs.exists(pasteScript.FilePath..pasteScript.FileName) then
- table.insert(existingPasteScripts,pasteScript)
- else
- table.insert(deletedScripts,pasteScript)
- end
- end
- settings.set("PastebinScripts",existingPasteScripts)
- settings.save()
- if #deletedScripts > 0 then
- term.clear()
- term.setCursorPos(1,1)
- print("Deleted "..tostring(#deletedScripts).." from PastebinScripts because\ntheir files have been deleted.\n")
- for i,pasteScript in pairs(deletedScripts) do
- print(" "..tostring(i).." - "..pasteScript.FilePath..pasteScript.FileName.." ("..pasteScript.PasteId..")")
- end
- print("\nPress Enter to continue...")
- io.read()
- term.clear()
- term.setCursorPos(1,1)
- end
- -- translate paste scripts into something this script handles
- for _,pasteScript in pairs(settings.get("PastebinScripts",{})) do
- table.insert(progs,{
- Name = pasteScript.FilePath..pasteScript.FileName,
- Id = pasteScript.PasteId
- })
- end
- for i,data in pairs(progs) do
- term.clear()
- term.setCursorPos(1,1)
- print("Updating ~")
- print()
- print("ID: "..data.Id)
- print("File: "..data.Name)
- print()
- if fs.exists(data.Name) then fs.delete(data.Name); end
- shell.run("pastebin get "..data.Id.." "..data.Name)
- term.clear()
- end
- os.reboot()
- end
- Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement