Advertisement
Marlingaming

Aperture Science OS System - App Menu 01

Sep 15th, 2021 (edited)
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2. --Client Program Manager
  3. --this program allows the user to see all download applications, management using inbuilt tools, start programs, etc
  4. --this program is for minecraft 1.16.5, cc tweaked
  5.  
  6. local AppAmount = 0
  7. local w, h = term.getSize()
  8. local AppName = {}
  9. local AppFile = {}
  10. local nOption = 0
  11.  
  12. function CenterText(y,text)
  13. local x = math.floor((w - string.len(text)) /2)
  14. term.setCursorPos(x,y)
  15. term.clearLine()
  16. term.write(text)
  17. end
  18.  
  19.  
  20. function GetApps()
  21. local file = fs.open("AppList","r")
  22. local Items = file.readLine(1)
  23. for i = 1, Items do
  24. AppName[i] = file.readLine(i*2)
  25. AppFile[i] = file.readLine(i*2+1)
  26. end
  27. file.close()
  28. end
  29.  
  30. function AppList()
  31.  
  32. end
  33.  
  34. local function drawMenu()
  35. term.clear()
  36. if nOption == 0 then
  37. term.setCursorPos(w-11,1)
  38. term.write("Exit")
  39. end
  40. for i = 1, #AppName do
  41. if nOption == i then
  42. term.setCursorPos(w-11,1)
  43. CenterText(1,AppName[i].." - "..AppFile[i])
  44. end
  45. end
  46. end
  47.  
  48. term.clear()
  49. local function drawFrontend()
  50. CenterText( math.floor(h/2) - 3, "")
  51. CenterText( math.floor(h/2) + 3, ((nOption == 0) and "[ Exit ]") or "Exit" )
  52. for i = 1, #AppName do
  53. CenterText( math.floor(h/2) + i+4, ((nOption == i) and "[ "..AppName[i].." ]") or AppName[i] )
  54. end
  55. end
  56.  
  57. GetApps()
  58. drawMenu()
  59. drawFrontend()
  60.  
  61. while true do
  62. local event, key = os.pullEvent("key")
  63. if key == keys.w or key == keys.up then
  64. nOption = nOption - 1
  65. elseif key == keys.s or key == keys.down then
  66. nOption = nOption + 1
  67. end
  68. if nOption < 0 then
  69. nOption = #AppName
  70. elseif nOption > #AppName then
  71. nOption = 0
  72. end
  73. drawMenu()
  74. drawFrontend()
  75. if key == keys.enter then
  76. break
  77. end
  78.  
  79. end
  80.  
  81. if nOption > 0 then
  82. if nOption == 1 then
  83. if fs.exists("ApertureDL_AppStore") == nil or fs.exists("ApertureOS_AppStore") == false then
  84. term.clearLine()
  85. local x, y = term.getCursorPos()
  86. term.setCursorPos((w - string.len("Downloading.....done!")/2), y)
  87. textutils.slowWrite("Downloading...done!")
  88. shell.run("C_Pastebin","run","SJ9gjJ6H")
  89. sleep(3)
  90. shell.run("ApertureDL_AppStore")
  91. else
  92. shell.run("ApertureDL_AppStore")
  93. end
  94. elseif nOption == 2 then
  95. shell.run("ApertureOS_SettingsMenu")
  96. else
  97. shell.run(AppFile[nOption])
  98. end
  99. elseif nOption == 0 then
  100. shell.run("ApertureOS_Base")
  101. else
  102.  
  103. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement