FoxOS

FoxOS Utility

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