· 5 years ago · Jun 10, 2020, 09:28 AM
1--[[
2Coded by Jelmar Man
3http://pastebin.com/u/thyJelmar
4
5This installs 'shop' and shortcut
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 Shopping System v1.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 ASS directory
58print("Adding directory 'ASS'...")
59if fs.exists("ASS") then
60 if fs.isDir("ASS") then
61 tc(colors.orange)
62 print("Directory 'ASS' already exists on this computer")
63 tc(colors.red)
64 print("Install terminated. Remove or rename directory 'ASS'")
65 return
66 else
67 tc(colors.orange)
68 print("ASS exists as a program. Renaming...")
69 pRename = "ASS"
70 repeat
71 pRename = pRename.."~"
72 until not fs.exists(pRename)
73 tc(colors.white)
74 print("Renamed ASS to "..pRename)
75 shell.run("rename ASS "..pRename)
76 end
77end
78tc(colors.white)
79fs.makeDir("ASS")
80print("Successfully added directroy 'ASS'")
81
82--Download Advanced Shopping System from pastebin
83print("Downloading program 'Advanced Shopping System' (ASS)...")
84if get("43dxZVYQ","ASS/ASS") then
85 print("Success")
86else
87 tc(colors.red)
88 print("Could not download. Is pastebin working?")
89 return
90end
91
92--Make Shortcut for Advanced Shopping System
93print("Downloading shortcut (ss)...")
94if fs.exists("ss") then
95 tc(colors.orange)
96 print("ss program already exists. Renaming...")
97 pRename = "ss"
98 repeat
99 pRename = pRename.."~"
100 until not fs.exists(pRename)
101 tc(colors.white)
102 print("Renamed ss to "..pRename)
103 shell.run("rename ss "..pRename)
104end
105if get("byhAwgqX","ss") then
106 print("Success")
107else
108 tc(colors.red)
109 print("Could not download. Is pastebin working?")
110 return
111end
112
113tc(colors.lime)
114print("Advanced Shopping System installed!")
115tc(colors.blue)
116print("Type 'rc' to run it, then follow the instruction to create the buttons")