Advertisement
Alexr360

Update Broken

Mar 26th, 2024 (edited)
1,042
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- List of programs to check for updates
  2. local programs = {
  3.     {name = "Bastion", pastebinCode = "Czt0xUgp"},
  4.     {name = "RBastion", pastebinCode = "YLMd18xC"},
  5.     {name = "FBastion", pastebinCode = "8pF6ds3s"},
  6.     {name = "GPS", pastebinCode = "d8WLzv0U"},
  7.     {name = "Update", pastebinCode = "8w6Ni2U1"},
  8.     {name = "Greeting", pastebinCode = "REfxrLkG"},
  9.     {name = "ArtilleryControl", pastebinCode = "BGUJrLzV"},
  10.     {name = "startup", pastebinCode = "u2ey5fkZ"},
  11.     {name = "todo", pastebinCode = "tfqc42mJ"},
  12.     {name = "Teleport", pastebinCode = "CLpkvMg8"}
  13.     -- Add more programs as needed
  14. }
  15.  
  16. -- Function to delete existing program files
  17. local function deleteFiles()
  18.     for _, program in ipairs(programs) do
  19.         if fs.exists(program.name) then
  20.             fs.delete(program.name)
  21.             print("Deleted " .. program.name)
  22.         end
  23.     end
  24. end
  25.  
  26. -- Function to download and update a single program
  27. local function updateProgram(program)
  28.     print("Updating " .. program.name .. "...")
  29.     local response = http.get("https://pastebin.com/raw/" .. program.pastebinCode)
  30.  
  31.     if response then
  32.         local remoteVersion = response.readAll()
  33.         response.close()
  34.  
  35.         local file = fs.open(program.name, "w")
  36.         file.write(remoteVersion)
  37.         file.close()
  38.  
  39.         print(program.name .. " updated successfully.")
  40.     else
  41.         print("Failed to update " .. program.name .. ". Check the Pastebin code or your internet connection.")
  42.     end
  43. end
  44.  
  45. -- Main function to delete all files and download new versions
  46. local function main()
  47.     deleteFiles() -- Delete all existing files first
  48.     for _, program in ipairs(programs) do
  49.         updateProgram(program)
  50.     end
  51. end
  52.  
  53.  
  54.  
  55. -- Run main function
  56. main()
  57.  
  58. shell.run("Greeting")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement