View difference between Paste ID: Q6dYBxD1 and 8w6Ni2U1
SHOW: | | - or go back to the newest paste.
1
-- List of programs to check for updates
2
local programs = {
3
    {name = "Bastion", pastebinCode = "Czt0xUgp"},
4-
    {name = "RBastion", pastebinCode = "YLMd18xC"},
4+
5-
    {name = "FBastion", pastebinCode = "8pF6ds3s"},
5+
    {name = "Update", pastebinCode = "Q6dYBxD1"},
6
    {name = "Greeting", pastebinCode = "TXcLTSsV"},
7-
    {name = "Update", pastebinCode = "8w6Ni2U1"},
7+
8-
    {name = "Greeting", pastebinCode = "T9Jf2wmy"},
8+
    {name = "startup", pastebinCode = "TXcLTSsV"},
9
    {name = "todo", pastebinCode = "tfqc42mJ"}
10-
    {name = "startup", pastebinCode = "u2ey5fkZ"},
10+
11-
    {name = "todo", pastebinCode = "tfqc42mJ"},
11+
12-
    {name = "Teleport", pastebinCode = "CLpkvMg8"}
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")