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