FoxOS

FoxOS Menu

Dec 29th, 2020 (edited)
72
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.  
  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.write("Impending OS Alpha // ")
  18. term.setCursorPos(1,2)
  19. shell.run("id")
  20.  
  21. term.setCursorPos(w-11,1)
  22. if nOption == 1 then
  23. term.write("Comandi")
  24. elseif nOption == 2 then
  25. term.write("LeNet")
  26. elseif nOption == 3 then
  27. term.write("WGet")
  28. elseif nOption == 4 then
  29. term.write("ChatDistance")
  30. elseif nOption == 5 then
  31. term.write("Spengi")
  32. elseif nOption == 6 then
  33. term.write("Disintalla FoxOS")
  34. else
  35. end
  36.  
  37. end
  38.  
  39. --GUI
  40. term.clear()
  41. local function drawFrontend()
  42. printCentered( math.floor(h/2) - 3, "")
  43. printCentered( math.floor(h/2) - 2, "Start Menu" )
  44. printCentered( math.floor(h/2) - 1, "")
  45. printCentered( math.floor(h/2) + 0, ((nOption == 1) and "[ Comandi ]") or "Comandi" )
  46. printCentered( math.floor(h/2) + 1, ((nOption == 2) and "[ LeNet ]") or "LeNet" )
  47. printCentered( math.floor(h/2) + 2, ((nOption == 3) and "[ WGet ]") or "WGet" )
  48. printCentered( math.floor(h/2) + 3, ((nOption == 4) and "[ ChatDistance ]") or "ChatDistance" )
  49. printCentered( math.floor(h/2) + 4, ((nOption == 5) and "[ Spegni ]") or "Spegni" )
  50. printCentered( math.floor(h/2) + 5, ((nOption == 6) and "[ Disinstalla ]") or "Disinstalla" )
  51. end
  52.  
  53. --Display
  54. drawMenu()
  55. drawFrontend()
  56.  
  57. while true do
  58. sleep(0.1)
  59. local e,p = os.pullEvent()
  60. if e == "key" then
  61. local key = p
  62. if key == 17 or key == 200 then
  63.  
  64. if nOption > 1 then
  65. nOption = nOption - 1
  66. drawMenu()
  67. drawFrontend()
  68. end
  69. elseif key == 31 or key == 308 then
  70. if nOption < 6 then
  71. nOption = nOption + 1
  72. drawMenu()
  73. drawFrontend()
  74. end
  75. elseif key == 28 then
  76. --End should not be here!!
  77. break
  78. end --End should be here!!
  79. end
  80. end
  81. term.clear()
  82.  
  83. --Conditions
  84. if nOption == 1 then
  85. shell.run(".FoxOS/.command")
  86. elseif nOption == 2 then
  87. shell.run(".FoxOS/.lenet")
  88. elseif nOption == 3 then
  89. shell.run(".FoxOS/.wget")
  90. elseif nOption == 4 then
  91. shell.run(".FoxOS/.dc")
  92. elseif nOption == 5 then
  93. os.shutdown()
  94. elseif nOption == 6 then
  95. shell.run(".FoxOS/.uninstall")
  96. else
  97. shell.run(".FoxOS/.what")
  98. end
Add Comment
Please, Sign In to add comment