Alexr360

Update V2

May 2nd, 2025 (edited)
340
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 = "GPS", pastebinCode = "d8WLzv0U"},
  5.     {name = "Update", pastebinCode = "Q6dYBxD1"},
  6.     {name = "Greeting", pastebinCode = "TXcLTSsV"},
  7.     {name = "ArtilleryControl", pastebinCode = "BGUJrLzV"},
  8.     {name = "startup", pastebinCode = "TXcLTSsV"},
  9.     {name = "todo", pastebinCode = "tfqc42mJ"}
  10.     -- Add more programs as needed
  11. }
  12.  
  13. -- Function to delete existing program files
  14. local function deleteFiles()
  15.     for _, program in ipairs(programs) do
  16.         if fs.exists(program.name) then
  17.             fs.delete(program.name)
  18.             print("Deleted " .. program.name)
  19.         end
  20.     end
  21. end
  22.  
  23. -- Function to download and update a single program
  24. local function updateProgram(program)
  25.     print("Updating " .. program.name .. "...")
  26.     local response = http.get("https://pastebin.com/raw/" .. program.pastebinCode)
  27.  
  28.     if response then
  29.         local remoteVersion = response.readAll()
  30.         response.close()
  31.  
  32.         local file = fs.open(program.name, "w")
  33.         file.write(remoteVersion)
  34.         file.close()
  35.  
  36.         print(program.name .. " updated successfully.")
  37.     else
  38.         print("Failed to update " .. program.name .. ". Check the Pastebin code or your internet connection.")
  39.     end
  40. end
  41.  
  42. -- Main function to delete all files and download new versions
  43. local function main()
  44.     deleteFiles() -- Delete all existing files first
  45.     for _, program in ipairs(programs) do
  46.         updateProgram(program)
  47.     end
  48. end
  49.  
  50.  
  51.  
  52. -- Run main function
  53. main()
  54.  
  55. shell.run("Greeting")
Advertisement
Add Comment
Please, Sign In to add comment