Advertisement
DOGGYWOOF

no

Jan 21st, 2024
3
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. nos.pullEvent = os.pullEventRaw
  2.  
  3. local w, h = term.getSize()
  4.  
  5. function printCentered(y, s)
  6. local x = math.floor((w - string.len(s)) / 2)
  7. term.setCursorPos(x, y)
  8. term.clearLine()
  9. term.write(s)
  10. end
  11.  
  12. local nOption = 1
  13.  
  14. local function drawMenu()
  15. term.clear()
  16. term.setCursorPos(1, 1)
  17. term.setTextColor(colors.cyan) -- Set text color to cyan
  18. term.write("Impending OS Alpha // ")
  19. term.setCursorPos(1, 2)
  20. term.setTextColor(colors.orange) -- Set text color to orange
  21. shell.run("id")
  22.  
  23. term.setCursorPos(w - 11, 1)
  24. if nOption == 1 then
  25. term.setTextColor(colors.green) -- Set text color to green for selected option
  26. term.write("Command")
  27. elseif nOption == 2 then
  28. term.setTextColor(colors.yellow) -- Set text color to yellow for selected option
  29. term.write("Programs")
  30. elseif nOption == 3 then
  31. term.setTextColor(colors.red) -- Set text color to red for selected option
  32. term.write("Shutdown")
  33. elseif nOption == 4 then
  34. term.setTextColor(colors.magenta) -- Set text color to magenta for selected option
  35. term.write("Uninstall")
  36. else
  37. term.setTextColor(colors.white) -- Reset text color
  38. end
  39. end
  40.  
  41. -- GUI
  42. term.clear()
  43. local function drawFrontend()
  44. term.setBackgroundColor(colors.black) -- Set background color to black
  45. term.clear()
  46. printCentered(math.floor(h / 2) - 3, "")
  47. printCentered(math.floor(h / 2) - 2, "Start Menu")
  48. printCentered(math.floor(h / 2) - 1, "")
  49. printCentered(math.floor(h / 2) + 0, ((nOption == 1) and "[ Command ]") or "Command")
  50. printCentered(math.floor(h / 2) + 1, ((nOption == 2) and "[ Programs ]") or "Programs")
  51. printCentered(math.floor(h / 2) + 2, ((nOption == 3) and "[ Shutdown ]") or "Shutdown")
  52. printCentered(math.floor(h / 2) + 3, ((nOption == 4) and "[ Uninstall]") or " Uninstall")
  53. printCentered(math.floor(h / 2) + 4, "")
  54. term.setBackgroundColor(colors.black) -- Reset background color
  55. end
  56.  
  57. -- Display
  58. drawMenu()
  59. drawFrontend()
  60.  
  61. while true do
  62. local e, p = os.pullEvent()
  63. if e == "key" then
  64. local key = p
  65. if key == 17 or key == 200 then
  66. if nOption > 1 then
  67. nOption = nOption - 1
  68. drawMenu()
  69. drawFrontend()
  70. end
  71. elseif key == 31 or key == 208 then
  72. if nOption < 4 then
  73. nOption = nOption + 1
  74. drawMenu()
  75. drawFrontend()
  76. end
  77. elseif key == 28 then
  78. break
  79. end
  80. end
  81. end
  82.  
  83. term.clear()
  84.  
  85. -- Conditions
  86. if nOption == 1 then
  87. shell.run("ios/.command")
  88. elseif nOption == 2 then
  89. shell.run("ios/.programs")
  90. elseif nOption == 3 then
  91. os.shutdown()
  92. else
  93. shell.run("ios/.UninstallDialog")
  94. end
  95.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement