Marlingaming

Heimbriech Tablet OS - Basic Menu System(Temp)

Sep 8th, 2021 (edited)
1,114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.51 KB | None | 0 0
  1. local oldPull = os.pullEvent
  2. os.pullEvent = os.pullEventRaw
  3. --this program for CC Tweaked acts as a Basic Menu for a tablet OS. this will be replaced in the future, with a better and more multipurpose Menu system(WIP)
  4. Current_Page = "Menu"
  5. Installed_Apps = []
  6. Access_Apps = [true,true,true,true,true]
  7. Access_Actions = []
  8.  
  9. start()
  10.  
  11. function start()
  12.     term.setBackgroundColor("blue")
  13.     term.setTextColor("white")
  14.     paintutils.drawFilledBox(1,19,26,20,color.gray)
  15.     paintutils.drawFilledBox(7,8,19,15,color.white)
  16.     paintutils.drawFilledBox(12,10,14,9,color.black)
  17.     MenuLoader()
  18. end
  19.  
  20. function MenuLoader()
  21.     local h = fs.open("InstalledApplications","r")
  22.     for i=1, #h.list do
  23.         Installed_Apps[i] = h.readline(i)
  24.     end
  25.     h.close()
  26.     DrawMenu()
  27.     Menu()
  28. end
  29.  
  30. function DrawMenu()
  31.     local X = 1
  32.     local Y = 1
  33.     for i=1, #15 do
  34.         if Installed_Apps[i] ~= nil then
  35.             paintutils.drawFilledBox(X*5,Y*5,(X*5)+5,(Y*5)+5,colors.white)
  36.             term.setCursorPos(X*5,Y*5)
  37.             term.write(Installed_Apps[i])
  38.         end
  39.         if X < 5 then
  40.             X = X+1
  41.         else
  42.             X = 1
  43.             Y = Y+1
  44.         end
  45.     end
  46.     X = 1
  47.     for i=1, #Access_Apps do
  48.         if Allowed_Apps[i] ~= true then
  49.             paintutils.drawFilledBox(X*3,18,(X*3)+2,20,colors.white)
  50.         end
  51.         X = X+1
  52.     end
  53. end
  54.  
  55. function Menu()
  56.     while true do --this checks to see if the mouse is pressed down, and where
  57.         local event, button, x, y = os.pullEvent("mouse_click")
  58.         if button == "left" and y >= 18 then --Checks what app the player clicked on Task Bar
  59.             TaskBarCheck(x)
  60.         else if button == "left" and x <= 2 and y <= 2 then --opens Settings
  61.             shell.run(".Heimbriech_SettingsMenu")
  62.         else --checks to see if User clicked on a Installed App on menu
  63.             InstalledApplicationCheck(x,y)
  64.         end
  65.     end
  66. end
  67.  
  68. function TaskBarCheck(x)
  69.     if x < 3 and Access_Apps[0] == true then --file manager
  70.  
  71.     else if x < 6 and Access_Apps[1] == true then --Store
  72.  
  73.     else if x < 9 and Access_Apps[2] == true then --Blank
  74.  
  75.     else if x < 12 and Access_Apps[3] == true then --Blank
  76.  
  77.     else if x < 15 and Access_Apps[4] == true then --Blank
  78.  
  79.     else
  80.  
  81.     end
  82. end
  83.  
  84. function InstalledApplicationCheck(x,y)
  85.     local X = 1
  86.     local Y = 1
  87.     local I = -1
  88.     for i=1, #15 do
  89.         if x > X*5 and x < (X*5)+5 and y > Y * 5 and y < (Y*5)+5 then
  90.             I = (X + (Y*5))-1
  91.         end
  92.         if X < 5 then
  93.             X = X + 1
  94.         else
  95.             X = 1
  96.             Y = Y + 1
  97.         end
  98.     end
  99.     if I > -1 then
  100.         OpenApplication(I)
  101.     end
  102. end
  103.  
  104. function OpenApplication(Number)
  105.     local Application_Name = Installed_Apps[Number]
  106.     shell.run("Launcher_"..Application_Name)
  107. end
  108. os.pullEvent = oldPull
Add Comment
Please, Sign In to add comment