· last year · May 26, 2024, 04:00 PM
1function clear() shell.run("clear") end
2function setColor(color) term.setTextColor(color) end
3
4function downloadFromPastebin(pasteID, fileName)
5 local path = shell.resolve(fileName)
6 if fs.exists(path) then
7 return false, "File already exists"
8 end
9
10 local response = http.get("http://pastebin.com/raw/" .. textutils.urlEncode(pasteID))
11 if response then
12 local content = response.readAll()
13 response.close()
14 local file = fs.open(path, "w")
15 file.write(content)
16 file.close()
17 return true, "Download successful"
18 else
19 return false, "Failed to download from Pastebin"
20 end
21end
22
23if not http then
24 print("HTTP API is disabled on this world/server")
25 return
26elseif not term.isColor() then
27 setColor(colors.red)
28 print("This program requires an advanced computer")
29 return
30end
31
32clear()
33setColor(colors.yellow)
34term.write("Advanced Redstone Control 3.0")
35setColor(colors.white)
36print(" is ready to be installed")
37setColor(colors.blue)
38print("Press any key...")
39
40os.pullEvent("key")
41os.pullEvent("char")
42
43clear()
44setColor(colors.white)
45print("Installing...")
46
47-- Add ARC directory
48print("Adding directory 'ARC'...")
49if fs.exists("ARC") then
50 if fs.isDir("ARC") then
51 setColor(colors.orange)
52 print("Directory 'ARC' already exists on this computer")
53 setColor(colors.red)
54 print("Install terminated. Remove or rename directory 'ARC'")
55 return
56 else
57 setColor(colors.orange)
58 print("ARC exists as a program. Renaming...")
59 local pRename = "ARC"
60 repeat
61 pRename = pRename .. "~"
62 until not fs.exists(pRename)
63 setColor(colors.white)
64 print("Renamed ARC to " .. pRename)
65 shell.run("rename ARC " .. pRename)
66 end
67end
68setColor(colors.white)
69fs.makeDir("ARC")
70print("Successfully added directory 'ARC'")
71
72-- Download Advanced Redstone Control from Pastebin
73local success, message = downloadFromPastebin("2ZPhx6ec", "ARC/ARC")
74print("Downloading program 'Advanced Redstone Control' (ARC)...")
75if success then
76 setColor(colors.lime)
77 print(message)
78else
79 setColor(colors.red)
80 print(message)
81 return
82end
83
84-- Download Config Editor
85print("Downloading program 'Config Editor' (configeditor)...")
86success, message = downloadFromPastebin("cKunvkD2", "ARC/configeditor")
87if success then
88 setColor(colors.lime)
89 print(message)
90else
91 setColor(colors.red)
92 print(message)
93 return
94end
95
96-- Make Shortcut for Advanced Redstone Control
97print("Downloading shortcut (rc)...")
98if fs.exists("rc") then
99 setColor(colors.orange)
100 print("rc program already exists. Renaming...")
101 local pRename = "rc"
102 repeat
103 pRename = pRename .. "~"
104 until not fs.exists(pRename)
105 setColor(colors.white)
106 print("Renamed rc to " .. pRename)
107 shell.run("rename rc " .. pRename)
108end
109success, message = downloadFromPastebin("y2pZUC3c", "rc")
110if success then
111 setColor(colors.lime)
112 print(message)
113else
114 setColor(colors.red)
115 print(message)
116 return
117end
118
119setColor(colors.lime)
120print("Advanced Redstone Control installed!")
121setColor(colors.blue)
122print("Type 'rc' to run it, then follow the instructions to create the buttons")
123