Advertisement
Marlingaming

Aperture Science OS System - Appstore_Browser

Sep 16th, 2021 (edited)
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. --Appstore Browser
  2. --this program is the Browser for the APP Store
  3. --this program is for Minecraft 1.16.5, CC Tweaked
  4.  
  5. local CurrentPastebinAppListCode = ""
  6. local AppStore_UseHTTP = false
  7. local AppNames = {}
  8. local AppHandler = {}
  9. local SearchTabState = false
  10. local Topic = ""
  11. local ShownApps = {}
  12. local ShownApps_Position = {}
  13. local ShownApps_File = {}
  14. local w,h = term.getSize()
  15.  
  16.  
  17.  
  18. function CenterText(y,text)
  19. local x = math.floor((w - string.len(text)) /2)
  20. term.setCursorPos(x,y)
  21. term.clearLine()
  22. term.write(text)
  23. end
  24.  
  25. function GetOnlineItems()
  26. local OnlineData_AppsList = nil
  27. if AppStore_UseHTTP == true then
  28.  
  29. elseif AppStore_UseHTTP == false then
  30. shell.run("C_Pastebin","get",CurrentPastebinAppListCode,"Temp_StoreAppLinks")
  31. end
  32. local file = fs.open("Temp_StoreAppLinks","r")
  33. for i = 1, #file.list()/2 do
  34. AppName[i] = file.readLine(i*2)
  35. AppHandler[i] = file.readLine(i*2+1)
  36. end
  37. file.close()
  38. end
  39.  
  40. function Clear()
  41. term.clear()
  42. term.setCursorPos(1,1)
  43. end
  44.  
  45. function DrawBrowser()
  46. Clear()
  47. print("App Browser")
  48. if AppStore_UseHTTP == false then
  49. print("HTTP USE BEEN DISABLED, FOR NOW ALL APPS ARE SHOWN FROM DEDICATED PASTEBIN LIST")
  50. end
  51. local L = 4
  52. local Line = nil
  53. for i = 1, #ShownApps/3 do
  54. Line = {ShownApps[i],ShownApps[i+1],ShownApps[i+2]}
  55. term.setCursorPos(10,L)
  56. term.write(Line[1])
  57. term.setCursorPos(20,L)
  58. term.write(Line[2])
  59. term.setCursorPos(30,L)
  60. term.write(Line[3])
  61. L = L + 5
  62. end
  63. end
  64.  
  65. function DrawImages()
  66. --not functional yet
  67. end
  68.  
  69. function SearchApps()
  70. ShownApps = {}
  71. local X = 1
  72. local Y = 1
  73. for i = 1, #AppNames do
  74. if string.find(AppNames[i],Topic) == true then
  75. ShownApps[#ShownApps+1] = AppNames[i]
  76. ShownApps_Postion[#ShownApps] = X, Y
  77. ShownApps_File[#ShownApps] = AppFile[i]
  78. if X < 3 then
  79. X = X + 1
  80. else
  81. X = 1
  82. Y = Y + 1
  83. end
  84. end
  85. end
  86. DrawBrowser()
  87. BROWSER()
  88. end
  89.  
  90. function findMouse(x,y)
  91. local X = 1
  92. local Y = 1
  93. local I = -1
  94. for i = 1, #ShownApps do
  95. if x < X*10 and y-5 < Y*5 then
  96. I = i
  97. else
  98. if X < 3 then
  99. X = X + 1
  100. else
  101. X = 1
  102. Y = Y + 1
  103. end
  104. end
  105. end
  106. if I == -1 then
  107. BROWSER()
  108. else
  109. fs.delete("Temp_StoreAppLinks")
  110. shell.run("ApertureDL_AppStore_AppPage",ShownApps_File[I],ShownApps_File[I])
  111. end
  112.  
  113. end
  114.  
  115. Clear()
  116. GetOnlineItems()
  117. DrawBrowser()
  118.  
  119.  
  120. function BROWSER()
  121. local input = read()
  122. while true do
  123. local event, Item, x, y = os.pullEvent()
  124. if event == "mouse_click" and x < 3 and y < 3 then
  125. shell.run("ApertureDL_AppStore")
  126. break
  127. elseif SearchBarState == true then
  128. if event == "key" and Item == keys.tab then
  129. SearchBarState = false
  130. elseif event == "key" and Item == keys.enter then
  131. Topic = input
  132. break
  133. elseif event == "key" then
  134. input = read()
  135. elseif event == mouse_click and Item == "left" and y > 5 then
  136. SearchBarState = false
  137. end
  138. elseif SearchBarState == false then
  139. if event == "key" ​and Item == keys.tab then
  140. SearchBarState = true
  141. elseif event == mouse_click and Item == "left" and y > 5 then
  142. if #ShownApps > 0 then
  143. findMouse(x, y)
  144. break
  145. end
  146. end
  147. end
  148. end
  149. SearchApps()
  150. end
  151.  
  152. BROWSER()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement