Marlingaming

Aperture Science OS System - AppStore_AppPage

Sep 17th, 2021 (edited)
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. --AppPage
  2. --this program shows the details of the Choosen App, and allows the User to either "Download", "Exit", or "Uninstall"
  3. --this program is for Minecraft 1.16.5, CC Tweaked
  4.  
  5.  
  6. local tArg = {..}
  7. local AppName = tArg[1]
  8. local AppDataCode = tArg[2]
  9. local AppAuthor = nil
  10. local AppDiscription = nil
  11. local AppLauncher = nil
  12. local ClientAppRelation = "Not Installed"
  13. local PageScroll = 1
  14. local AppDownloadCode = nil
  15. local y,h = term.getSize()
  16.  
  17.  
  18. term.clear()
  19. term.setcursorPos(1,1)
  20. print("APP PAGE")
  21.  
  22. function CenterText(y,text)
  23. local x = math.floor((y - string.len(text)) /2)
  24. term.setCursorPos(x,y)
  25. term.clearLine()
  26. term.write(text)
  27. end
  28.  
  29. function Download()
  30. fs.delete("Temp_AppData")
  31. shell.run(AppDownloadCode)
  32. local Apps = fs.open("AppList","a")
  33. local i = #AppList.list()
  34. AppList.setCursorPos(1,i+1)
  35. AppList.writeLine(AppName)
  36. AppList.writeLine(AppLauncher)
  37. AppList.close()
  38. shell.run(".ApertureOS_AppMenu")
  39. end
  40.  
  41. function GetAppData()
  42. shell.run("pastebin","get",AppDataCode,"Temp_AppData")
  43. local file = fs.open("Temp_AppData","r")
  44. AppAuthor = file.readLine(3)
  45. AppDiscription = file.readLine(4)
  46. AppLauncher = file.readLine(5)
  47. AppDownloadCode = file.readLine(7)
  48. file.close()
  49. end
  50.  
  51. function DrawMenu()
  52. term.setBackground(colors.white)
  53. paintutils.drawFilledBox(40,3,48,5,colors.green)
  54. term.setCursorPos(41,4)
  55. term.write("Download")
  56. CenterText(4,AppName)
  57. CenterText(6,AppAuthor)
  58. paintutils.drawFilledBox(1,1,3,3,colors.red)
  59. paintutils.drawLine(1,1,3,3,colors.black)
  60. paintutils.drawLine(1,3,3,1,colors.black)
  61. paintutils.drawFilledBox(2,8,49,30,colors.white)
  62. local Lines = require"cc.strings".wrap(AppDiscription, 45)
  63. for i = 1 #Lines do
  64. term.setCursorPos(3,i+9)
  65. term.write(Lines[i])
  66. end
  67. end
  68.  
  69. GetAppData()
  70. DrawMenu()
  71.  
  72. while true do
  73. local event, Item, x, y = os.pullEvent()
  74. if event == "mouse_click" and x > 40 and x < 48 and y > 3 and y < 5 and ClientAppRelation == "Not Installed" then --clicked on Download Button
  75. paintutils.drawFilledBox(10,4,40,8,colors.gray)
  76. CenterText(6,"DOWNLOADING APPLICATION, PLEASE WAIT")
  77. term.setCursorPos(10,7)
  78. textutils.slowWrite("==============================")
  79. sleep(20)
  80. Download()
  81. break
  82. elseif event == "mouse_click" and x < 3 and y < 3 then --returns back to Store Menu, not the browser
  83. shell.run(".ApertureOS_AppStore")
  84. break
  85. elseif event == "key" and Item == keys.down and PageScroll < 40 then
  86. PageScroll = PageScroll + 1
  87. term.scroll(1)
  88. elseif event == "key" and Item == keys.up and Page Scroll > 1 then
  89. PageScroll = PageScroll - 1
  90. term.scroll(-1)
  91. end
  92. DrawMenu()
  93. end
  94.  
  95.  
Add Comment
Please, Sign In to add comment