FoxOS

.wget

Feb 11th, 2021
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 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("Installa")
  26. elseif nOption == 3 then
  27. term.write("Lista")
  28. elseif nOption == 4 then
  29. term.write("Aggiorna")
  30. else
  31. end
  32.  
  33. end
  34.  
  35. --GUI
  36. term.clear()
  37. local function drawFrontend()
  38. printCentered( math.floor(h/2) - 3, "")
  39. printCentered( math.floor(h/2) - 2, "Utilità" )
  40. printCentered( math.floor(h/2) - 1, "")
  41. printCentered( math.floor(h/2) + 0, ((nOption == 1) and "> Torna Indietro") or "Torna Indietro" )
  42. printCentered( math.floor(h/2) + 1, ((nOption == 2) and "> Installa un WGet") or "Installa un WGet" )
  43. printCentered( math.floor(h/2) + 2, ((nOption == 3) and "> Visualizza i tuoi WGet") or "Visualizza i tuoi WGet" )
  44. printCentered( math.floor(h/2) + 3, ((nOption == 4) and "> Aggiorna la Lista") or "Aggiorna la Lista" )
  45. end
  46.  
  47. --Display
  48. drawMenu()
  49. drawFrontend()
  50.  
  51. while true do
  52. sleep(0.1)
  53. local e,p = os.pullEvent()
  54. if e == "key" then
  55. local key = p
  56. if key == 17 or key == 200 then
  57.  
  58. if nOption > 1 then
  59. nOption = nOption - 1
  60. drawMenu()
  61. drawFrontend()
  62. end
  63. elseif key == 31 or key == 208 then
  64. if nOption < 4 then
  65. nOption = nOption + 1
  66. drawMenu()
  67. drawFrontend()
  68. end
  69. elseif key == 28 then
  70. --End should not be here!!
  71. break
  72. end --End should be here!!
  73. end
  74. end
  75. term.clear()
  76.  
  77. --Conditions
  78. if nOption == 1 then
  79. shell.run(".FoxOS/.menu")
  80. elseif nOption == 2 then
  81. shell.run(".FoxOS/.wgetinstall")
  82. elseif nOption == 3 then
  83. shell.run(".FoxOS/.wgetlist")
  84. elseif nOption == 4 then
  85. shell.run(".FoxOS/.wgetreload")
  86. else
  87. shell.run(".FoxOS/.what")
  88. end
Advertisement
Add Comment
Please, Sign In to add comment