Marlingaming

CC Tweaked AppStore

Jan 13th, 2022 (edited)
737
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.49 KB | None | 0 0
  1. --this application acts as a App store
  2. local tArg = {...}
  3. local AllowedApps = {}
  4. local OwnedState = {}
  5. local w, h = term.getSize()
  6.  
  7. settings.load(".settings")
  8. local TopApps = {}
  9.  
  10. local function Clear()
  11. term.setBackgroundColor(colors.orange)
  12. term.clear()
  13. term.setCursorPos(1,1)
  14. end
  15.  
  16. local function SetAppList()
  17. AllowedApps = tArg[2]
  18. TopApps = tArg[3]
  19. end
  20.  
  21. local function GetAppList()
  22. shell.run("pastebin","run","DbZGEdRt")
  23. end
  24.  
  25. function CUI(m,x,y) --declare function
  26. n=1
  27. local l = #m
  28. while true do
  29. term.setCursorPos(x,y)
  30.  
  31. for i = 1, #m do
  32.  
  33. if i==n then term.clearLine() print("<"..m[i]..">") else term.clearLine() print(m[i]) end
  34. local Cor = {term.getCursorPos()}
  35. term.setCursorPos(x,Cor[2])
  36. end
  37. local a, b = os.pullEvent("key")
  38. if b==keys.w and n>1 then n=n - 1 end
  39. if b==keys.s and n<l then n=n+1 end
  40. if b==keys.enter then break end
  41. end
  42. return n --return the value
  43. end
  44.  
  45. function PageLoader_Touch(Name)
  46. local I
  47. for i = 1, #AllowedApps do
  48.     if AllowedApps[i][1] == Name then I = i end
  49. end
  50. Clear()
  51. local AppName = Name
  52. local Author = AllowedApps[I][2]
  53. local Description = AllowedApps[I][4]
  54. local Code = AllowedApps[I][6]
  55. print("[X]")
  56. print(AppName)
  57. print(Author)
  58. print("==Download==")
  59. print(Description)
  60. local event
  61. local Result = "n"
  62. while true do
  63.     event = {os.pullEvent()}
  64.     if event[1] == "key" and event[2] == keys.x then Result = "exit" end
  65.     if event[1] == "mouse_click" and event[3] < 3 and event[4] < 1 then Result = "exit" end
  66.     if event[1] == "mouse_click" and event[3] < 11 and event[4] == 4 then Result = "Download" end
  67. if Result == "exit" or Result == "Download" then break end
  68. end
  69. if Results == "exit" then
  70.     AppMenu_1()
  71. elseif Results == "Download" then
  72.     shell.run("pastebin","run",Code)
  73.     PageLoader_Touch(Name)
  74. end
  75. end
  76.  
  77. function PageLoader_Key(Name)
  78. local I
  79. for i = 1, #AllowedApps do
  80.     if AllowedApps[i][1] == Name then I = i end
  81. end
  82. Clear()
  83. local AppName = Name
  84. local Author = AllowedApps[I][2]
  85. local Description = AllowedApps[I][4]
  86. local Cost = AllowedApps[I][5]
  87. local Code = AllowedApps[I][6]
  88. print("===============")
  89. print(AppName)
  90. print(Author)
  91. print(Description)
  92. local options = {"Buy","exit"}
  93. if Cost == 0 then
  94.     options[1] = "Download"
  95. else
  96.     options[1] = "Buy | "..Cost.."C |"
  97. local n = CUI(options,3,7)
  98. if n == 1 then
  99.     if AllowedApps[i][7] == true then
  100.         shell.run("pastebin","run",Code)
  101.     else
  102.         shell.run("os/os_Programs/Scripts/ProvidedInstaller",AllowedPrograms[i][7][1],AllowedPrograms[i][6],AllowedPrograms[i][7][2])
  103.     PageLoader_Key(Name)
  104. elseif n == 2 then
  105.     AppMenu_2()
  106. end
  107. end
  108.  
  109. function AppMenu_1()
  110. Clear()
  111. print("[X] App Store")
  112. print("[search bar]")
  113. local options = TopApps
  114. options[#options + 1] = "exit"
  115. local n = CUI(options,3,3)
  116. if n == 0 then
  117.     shell.run(settings.get("os_DesktopLoc"))
  118. else
  119.     PageLoader_Touch(TopApps[n])
  120. end
  121. end
  122.  
  123. function AppMenu_2()
  124. Clear()
  125. term.setBackgroundColor(colors.lightGray)
  126.  
  127. term.clearLine()
  128. term.setCursorPos(1,2)
  129. term.clearLine()
  130. term.setCursorPos(1,1)
  131.  
  132. print("App Store")
  133. print("[search bar]")
  134.  
  135. paintutils.drawFilledBox(1,h - 3, w, h, colors.lightGray)
  136. term.setBackgroundColor(colors.orange)
  137. local options = TopApps
  138. options[#options + 1] = "exit"
  139. local n = CUI(options,7,4)
  140. if options[n] == "exit" then
  141.     shell.run(settings.get("os_DesktopLoc"))
  142. else
  143.     PageLoader_Key(TopApps[n])
  144. end
  145. end
  146. if tArg[1] == "Ready" then
  147.     SetAppList()
  148. else
  149.     GetAppList()
  150. end
  151.  
  152. if settings.get("os_TouchScreen") == true then
  153.     AppMenu_1()
  154. else
  155.     AppMenu_2()
  156. end
Add Comment
Please, Sign In to add comment