SHOW:
|
|
- or go back to the newest paste.
| 1 | -- List of programs to check for updates | |
| 2 | local programs = {
| |
| 3 | - | {name = "Bastion", pastebinCode = "YLMd18xC"},
|
| 3 | + | {name = "Bastion", pastebinCode = "Czt0xUgp"},
|
| 4 | {name = "RBastion", pastebinCode = "YLMd18xC"},
| |
| 5 | - | {name = "Update", pastebinCode = "RAVBceBu"},
|
| 5 | + | {name = "FBastion", pastebinCode = "8pF6ds3s"},
|
| 6 | - | {name = "startup", pastebinCode = "REfxrLkG"},
|
| 6 | + | |
| 7 | - | {name = "startup", pastebinCode = "REfxrLkG"},
|
| 7 | + | {name = "Update", pastebinCode = "8w6Ni2U1"},
|
| 8 | - | {name = "ArtillaryControl", pastebinCode = "BGUJrLzV"},
|
| 8 | + | {name = "Greeting", pastebinCode = "T9Jf2wmy"},
|
| 9 | - | {name = "StargateLogs", pastebinCode = "eg0sWHxc"}
|
| 9 | + | {name = "ArtilleryControl", pastebinCode = "BGUJrLzV"},
|
| 10 | {name = "startup", pastebinCode = "u2ey5fkZ"},
| |
| 11 | {name = "todo", pastebinCode = "tfqc42mJ"},
| |
| 12 | {name = "Teleport", pastebinCode = "CLpkvMg8"}
| |
| 13 | - | -- Function to check for updates |
| 13 | + | |
| 14 | - | local function checkForUpdates(program) |
| 14 | + | |
| 15 | - | -- Loop through the list of programs |
| 15 | + | |
| 16 | - | for i, program in ipairs(programs) do |
| 16 | + | -- Function to delete existing program files |
| 17 | - | -- Check if the file already exists |
| 17 | + | local function deleteFiles() |
| 18 | - | if not fs.exists(program.name) then |
| 18 | + | |
| 19 | - | -- Open a new file with the current program name |
| 19 | + | if fs.exists(program.name) then |
| 20 | fs.delete(program.name) | |
| 21 | print("Deleted " .. program.name)
| |
| 22 | - | -- Write a message to the file |
| 22 | + | |
| 23 | - | file.write("This is " .. program.name .. ". The pastebin code is " .. program.pastebinCode)
|
| 23 | + | |
| 24 | end | |
| 25 | - | -- Close the file |
| 25 | + | |
| 26 | -- Function to download and update a single program | |
| 27 | - | end |
| 27 | + | local function updateProgram(program) |
| 28 | print("Updating " .. program.name .. "...")
| |
| 29 | - | print("Files have been created.")
|
| 29 | + | |
| 30 | - | |
| 30 | + | |
| 31 | - | print("Checking for updates for " .. program.name .. "...")
|
| 31 | + | |
| 32 | local remoteVersion = response.readAll() | |
| 33 | response.close() | |
| 34 | ||
| 35 | local file = fs.open(program.name, "w") | |
| 36 | - | local localVersion = fs.exists(program.name) and fs.open(program.name, "r").readAll() or nil |
| 36 | + | file.write(remoteVersion) |
| 37 | - | if localVersion and localVersion ~= remoteVersion then |
| 37 | + | |
| 38 | - | print("Updating " .. program.name .. "...")
|
| 38 | + | |
| 39 | - | local file = fs.open(program.name, "w") |
| 39 | + | print(program.name .. " updated successfully.") |
| 40 | - | file.write(remoteVersion) |
| 40 | + | |
| 41 | - | file.close() |
| 41 | + | print("Failed to update " .. program.name .. ". Check the Pastebin code or your internet connection.")
|
| 42 | - | print(program.name .. " updated successfully.") |
| 42 | + | |
| 43 | - | else |
| 43 | + | |
| 44 | - | print(program.name .. " is up to date.") |
| 44 | + | |
| 45 | -- Main function to delete all files and download new versions | |
| 46 | local function main() | |
| 47 | - | print("Failed to check for updates for " .. program.name)
|
| 47 | + | deleteFiles() -- Delete all existing files first |
| 48 | for _, program in ipairs(programs) do | |
| 49 | updateProgram(program) | |
| 50 | end | |
| 51 | - | -- Main function to check for updates for all programs |
| 51 | + | |
| 52 | ||
| 53 | ||
| 54 | - | checkForUpdates(program) |
| 54 | + | |
| 55 | -- Run main function | |
| 56 | main() | |
| 57 | ||
| 58 | shell.run("Greeting") |