Marlingaming

CC Tweaked CCSPS Iron - AppStore Online

Jan 31st, 2022 (edited)
534
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.63 KB | None | 0 0
  1. local Apps_Details = {{"Account","os/System/Programs/UserAccount.lua","FXT5QKny"},{"Settings","os/System/Programs/SettingsMenu.lua","HiXY2vKq"},{"Ex install","os/System/Programs/ExInstall.lua","BkGvhc2g"},{"Help","os/System/Programs/InstructionManual.lua","f0vUBCJB"},{"TrainNet","os/System/Programs/TrainNet.lua","t9inpEHU"},{"ImperialExplorer","os/System/Programs/ImperialWebBrowser.lua","2NVqG6bt"}}
  2.  
  3. local AppScores = {{50,"UserManagement,Gov", 1642687200},{20,"Audio,Speaker,Music", 1642514400},{10,"FileManagement,Downloader,DiskDrive", 1642860000},{30,"Os,FileManagement", 1642946400},{35,"Info,Os",1643464800},{3,"Net,Info,Gov", 1643637600},{2,"Net", 1643810400}}
  4.  
  5. local SupportedApps = {"Account","Ex","Settings","Help","TrainNet","ImperialWebBrowser","exit"}
  6.  
  7. local Apps_Disc = {"account","settings","ex install","manual","WIP allows easy access to information and tickets for the National Rail Network","Allows easy browsing of Ingame Web servers"}
  8. local Apps_Updates = {"1.0.0","1.0.0","1.0.0","1.0.0","1.0.0","1.0.0","1.0.0"}
  9. local Apps_Installed = {false,false,false,false,false,false,false}
  10. local AppData = {}
  11.  
  12. local w, h = term.getSize()
  13. local SearchCat = "all"
  14.  
  15. local function Clear()
  16. term.clear()
  17. term.setCursorPos(1,1)
  18. end
  19.  
  20. local function FindApps()
  21. local Files = fs.list("os/System/Programs")
  22. for i = 1, #Apps_Details do
  23.     if fs.exists(Apps_Details[i][2]) then Apps_Installed[i] = true end
  24. end
  25. end
  26.  
  27. local function AppFiles()
  28. local Path = "os/System/Client/Files/AppStore"
  29. local Apps = fs.list(Path)
  30. for i = 1, #Apps do
  31.     local It = fs.combine(Path,Apps[i])
  32.     local file = fs.open(It,"r")
  33.     AppData[i] = textutils.unserialize(file.readAll())
  34.     file.close()
  35. end
  36. end
  37.  
  38. local function SaveFile(I)
  39.  
  40. local Path = "os/System/Client/Files/AppStore"
  41. local Apps = fs.list(Path)
  42.  
  43.  
  44. local file = fs.open(fs.combine(Path,App_Details[I][1]),"w")
  45. file.clear()
  46. file.setCursorPos(1,1)
  47. file.write(textutils.serialize(AppData[I]))
  48. file.close()
  49. end
  50.  
  51. function CUI(m) --declare function
  52. n=1
  53. local l = #m
  54. while true do
  55. term.setCursorPos(1,5)
  56. for i=1, #m, 1 do --traverse the table of options
  57. if i==n then term.clearLine() print(i, ">",m[i]) else term.clearLine() print(i, "-", m[i]) end --print them
  58. end
  59. a, b= os.pullEvent("key") --wait for keypress
  60. if b==keys.w and n>1 then n=n-1 end
  61. if b==keys.s and n<l then n=n+1 end
  62. if b==keys.enter then break end
  63. end
  64. return n --return the value
  65. end
  66.  
  67. function AppListTouch(m) --declare function
  68. n=0
  69. local l = #m
  70. while true do
  71. term.setCursorPos(1,4)
  72. for i = 1, #m do
  73.     print("[ ",m[i]," ]")
  74.     print("-")
  75. end
  76. a, b, c, d = os.pullEvent("mouse_click") --wait for keypress
  77. for i = 1, #m do
  78.     if d == (i * 2) + 2 then n = i end
  79. end
  80. if c < 3 and d < 3 then n = 50 end
  81. if n > 0 then break end
  82. end
  83. return n --return the value
  84. end
  85.  
  86. local function InstallApp(I)
  87. local Shortcut
  88. local Image = "n"
  89. Clear()
  90. print("create Desktop shortcut?")
  91. print("> yes")
  92. print("or")
  93. print("> no")
  94. local a, b, c, d
  95. repeat
  96.     a, b, c, d = os.pullEvent("mouse_click")
  97. until d == 2 or d == 4
  98. if d == 2 then
  99.     Shortcut = {true,"Desktop",Image}
  100. else
  101.     Shortcut = {false,"n","n"}
  102. end
  103. print("downloading")
  104. local data = {{Apps_Details[I][1],Apps_Details[I][2],Apps_Details[I][3],Shortcut[1],Shortcut[2],Shortcut[3]}}
  105. local file = fs.open("os/External/Download","w")
  106. file.write(textutils.serialize(data))
  107. file.close()
  108. shell.run( "os/System/Programs/InstallHandler.lua","os/External/Download")
  109. Apps_Installed[I] = true
  110. os.sleep(2)
  111. end
  112.  
  113. local function UpdateApp(I)
  114. fs.delete(Apps_Details[I][2])
  115. shell.run(settings.get("osPaster"),"get",Apps_Details[I][3],Apps_Details[I][2])
  116. AppData[I][3] = Apps_Updates[I]
  117. end
  118.  
  119. function Page(I)
  120. local HasUpdate = false
  121. term.setBackgroundColor(colors.white)
  122. term.setTextColor(colors.black)
  123. Clear()
  124. print("[X]===",Apps_Details[I][1],"===")
  125. term.setCursorPos(1,4)
  126. if Apps_Installed[I] == true then
  127.     if HasUpdate == true then print("[Update]") else print("[Installed]") end
  128. else
  129.     print("[Download]")
  130.     print("Recently Updated? ",Apps_Updates[I])
  131. end
  132. term.setCursorPos(1,6)
  133. print(Apps_Disc[I])
  134. local Action
  135. repeat
  136.     local event, a, b, c = os.pullEvent("mouse_click")
  137.     if b < 8 and c == 4 then Action = "Inter" end
  138.     if b < 4 and c == 1 then Action = "exit" end
  139. until Action == "Inter" or Action == "exit"
  140. if Action == "Inter" then
  141.     if Apps_Installed[I] == false then
  142.         InstallApp(I)
  143.     elseif HasUpdate == true then
  144.         UpdateApp(I)
  145.     end
  146.     Page(I)
  147. elseif Action == "exit" then
  148.     DisplayMenu()
  149. end
  150. end
  151.  
  152. function Menu()
  153. term.setBackgroundColor(colors.green)
  154. term.setTextColor(colors.white)
  155. Clear()
  156. term.setCursorPos(1,8)
  157. print("Coming Soon!")
  158. print(">touch screen compatibility")
  159. print(">Search system")
  160. print(">Market System")
  161. print(">banking_public2 integration")
  162. local options = {"New","exit"}
  163. local n = CUI(options)
  164. if options[n] == "exit" then
  165.     term.setTextColor(colors.white)
  166.  
  167. elseif options[n] == "Net" then
  168.  
  169. elseif options[n] == "New" then
  170.     DisplayMenu(SetList("New"))
  171. elseif options[n] == "Trending" then
  172.    
  173. elseif options[n] == "Owned" then
  174.     DisplayMenu(SetList("Owned"))
  175. end
  176. end
  177.  
  178. function SetList(Cat)
  179. local List = {}
  180. for i = 1, #Apps_Details do
  181.     List[i] = Apps_Details[i][1]
  182. end
  183. return(List)
  184. end
  185.  
  186. function DisplayMenu()
  187. term.setBackgroundColor(colors.green)
  188. term.setTextColor(colors.white)
  189. Clear()
  190. paintutils.drawBox(1,1,2,2,colors.red)
  191. term.setBackgroundColor(colors.green)
  192. term.setCursorPos(3,1)
  193. term.write("AppStore")
  194. local options = SetList()
  195. local n = AppListTouch(options)
  196. if n == 50 then
  197.     Menu()
  198. else
  199.     Page(n)
  200. end
  201. end
  202.  
  203. FindApps()
  204. AppFiles()
  205. Menu()
Add Comment
Please, Sign In to add comment