FoxOS

.wgetmenu

Jan 8th, 2021 (edited)
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 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("FoxOS by FoxWorn3365 | 2020")
  18. term.setCursorPos(1,2)
  19. shell.run("id")
  20.  
  21. term.setCursorPos(w-11,1)
  22. if nOption == 1 then
  23. term.write("Indietro")
  24. elseif nOption == 2 then
  25. term.write("Importa")
  26. elseif nOption == 3 then
  27. term.write("Lista")
  28. elseif nOption == 4 then
  29. term.write("Esegui")
  30. elseif nOption == 5 then
  31. term.write("Aggiorna")
  32. elseif nOption == 6 then
  33. term.write("Cosa Sono")
  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, "Menu WGet" )
  44. printCentered( math.floor(h/2) - 1, "")
  45. printCentered( math.floor(h/2) + 0, ((nOption == 1) and " > Torna Indietro") or "Torna Indietro" )
  46. printCentered( math.floor(h/2) + 1, ((nOption == 2) and "> Importa un WGet") or "Importa un WGet" )
  47. printCentered( math.floor(h/2) + 2, ((nOption == 3) and "> Visualizza i WGet") or "Visualizza i WGet" )
  48. printCentered( math.floor(h/2) + 3, ((nOption == 4) and "> Esegui un WGet") or "Esegui un WGet" )
  49. printCentered( math.floor(h/2) + 4, ((nOption == 5) and "> Aggiorna la Lista") or "Aggiorna la Lista" )
  50. printCentered( math.floor(h/2) + 5, ((nOption == 6) and "> Cosa sono i WGet") or "Cosa sono i WGet" )
  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. print("")
  64. if nOption > 1 then
  65. nOption = nOption - 1
  66. drawMenu()
  67. drawFrontend()
  68. end
  69. elseif key == 31 or key == 208 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/.menu")
  86. elseif nOption == 2 then
  87. shell.run(".FoxOS/.wgeti")
  88. elseif nOption == 3 then
  89. shell.run(".FoxOS/.wgetv")
  90. elseif nOption == 4 then
  91. shell.run(".FoxOS/.wgete")
  92. elseif nOption == 5 then
  93. shell.run(".FoxOS/.wgeta")
  94. elseif nOption == 6 then
  95. shell.run(".FoxOS/.wgeti")
  96. else
  97. shell.run(".FoxOS/.what")
  98. end
Add Comment
Please, Sign In to add comment