06NinjaKid06

menu

Jun 20th, 2023 (edited)
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.59 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2. local w,h = term.getSize()
  3.  
  4. local function printCentered (y,s)
  5.  
  6.     local x = math.floor((w - string.len(s)) / 2)
  7.     term.setCursorPos(x,y)
  8.     term.clearLine()
  9.     term.write(s)
  10.  
  11.  
  12. local nOption = 1
  13.  
  14. local function drawMenu()
  15.     term.clear()
  16.     term.setCursorPos(1,1)
  17.     term.write("MinerOS V1.0")
  18. term.setCursorPos(1,2)
  19.  
  20. term.setCursorPos(w-11,1)
  21. if nOption == 1 then
  22.     term.write("Command Prompt")
  23. elseif nOption == 2 then
  24.     term.write("Applications")
  25. elseif nOption == 3 then
  26.     term.write("Power Options")
  27. elseif nOption == 4 then
  28.     term.write("File Viewer")
  29. elseif nOption == 5 then
  30.     term.write("Uninstall :(")
  31. else
  32. end
  33.  
  34. end
  35.  
  36. --GUI lol
  37. term.setBackgroundColor(colors.orange)
  38. term.clear()
  39. local function drawFrontend()
  40.     printCentered(math.floor(h/2) - 3, "")
  41.     printCentered(math.floor(h/2) - 2, "Start Menu")
  42.     printCentered(math.floor(h/2) - 1, "")
  43.     printCentered(math.floor(h/2) + 0, ((nOption == 1) and "> Command Prompt <") or "Command Prompt")
  44.     printCentered(math.floor(h/2) + 1, ((nOption == 2) and ">  Applications  <") or "Applications")
  45.     printCentered(math.floor(h/2) + 2, ((nOption == 3) and ">  Power Options <") or "Power Options")
  46.     printCentered(math.floor(h/2) + 3, ((nOption == 4) and ">  File Viewer   <") or "File Viewer")
  47.     printCentered(math.floor(h/2) + 4, ((nOption == 5) and ">  Uninstall :(  <") or "Uninstall :(")
  48.     printCentered(math.floor(h/2) + 5, "")
  49.     end
  50.    
  51.     --Display uit please fghklfgnhmfgnhlkgfnl
  52.     drawMenu()
  53.     drawFrontEnd()
  54.    
  55.     while true do
  56.         local e,p = os.pullEvent()
  57.         if e == "keys" then
  58.             local keys = p
  59.             if keys == 17 or keys == 200 then
  60.            
  61.                 if nOption > 1 then
  62.                     nOption = nOption + 1
  63.                     drawMenu()
  64.                     drawFrontend()
  65.                 end
  66.                 elseif keys == 31 or keys == 209 then
  67.                     if nOption < 5 then
  68.                     nOption = nOption + 1
  69.                     drawMenu()
  70.                     drawFrontend()
  71.                 end
  72.                 elseif keys == 28 then
  73.                
  74.                 break
  75.                 end
  76.             end
  77.         end
  78.     term.clear()
  79.     --Conditons
  80.     if nOption == 1 then
  81.         exit()
  82.     elseif nOption == 2 then
  83.         print("wait for next version!!11!!")
  84.     elseif nOption == 3 then
  85.         os.shutdown()
  86.     elseif nOption == 4 then
  87.         print("not eyt !!!@!@@2465234652436")
  88.     else
  89.         print("soon")
  90.     end
  91.                
  92. end
  93.  
Advertisement
Add Comment
Please, Sign In to add comment