FoxOS

.commands

Dec 30th, 2020 (edited)
63
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("Indietro")
  24. elseif nOption == 2 then
  25.    term.write("LUA")
  26. elseif nOption == 3 then
  27.    term.write("Monitors")
  28. elseif nOption == 4 then
  29.    term.write("MKDir")
  30. elseif nOption == 5 then
  31.    term.write("Copia")
  32. elseif nOption == 6 then
  33.    term.write("Sposta")
  34. elseif nOption == 7 then
  35.    term.write("Elimina")
  36. elseif nOption == 8 then
  37.    term.write("Help")
  38. else
  39. end
  40.  
  41. end
  42.  
  43. --GUI
  44. term.clear()
  45. local function drawFrontend()
  46.    printCentered( math.floor(h/2) - 3, "")
  47.    printCentered( math.floor(h/2) - 2, "Menu Principale" )
  48.    printCentered( math.floor(h/2) - 1, "")
  49.    printCentered( math.floor(h/2) + 0, ((nOption == 1) and "[ Menu Principale ]") or "Menu Principale" )
  50.    printCentered( math.floor(h/2) + 1, ((nOption == 2) and "[ Interfaccia LUA ]") or "Interfaccia LUA" )
  51.    printCentered( math.floor(h/2) + 2, ((nOption == 3) and "[ Monitors ]") or "Monitors" )
  52.    printCentered( math.floor(h/2) + 3, ((nOption == 4) and "[ MKDir ]") or "MKDir" )
  53.    printCentered( math.floor(h/2) + 4, ((nOption == 5) and "[ Copia ]") or "Copia" )
  54.    printCentered( math.floor(h/2) + 5, ((nOption == 6) and "[ Sposta ]") or "Sposta" )
  55.    printCentered( math.floor(h/2) + 6, ((nOption == 7) and "[ Cancella ]") or "Cancella" )
  56.    printCentered( math.floor(h/2) + 7, ((nOption == 8) and "[ Aiuto Comandi ]") or "Aiuto Comandi" )
  57. end
  58.  
  59. --Display
  60. drawMenu()
  61. drawFrontend()
  62.  
  63. while true do
  64.  sleep(0.1)
  65.  local e,p = os.pullEvent()
  66.  if e == "key" then
  67.   local key = p
  68.   if key == 17 or key == 200 then
  69.   print("")
  70.    if nOption > 1 then
  71.     nOption = nOption - 1
  72.     drawMenu()
  73.     drawFrontend()
  74.    end
  75.   elseif key == 31 or key == 208 then
  76.   if nOption < 8 then
  77.   nOption = nOption + 1
  78.   drawMenu()
  79.   drawFrontend()
  80. end
  81. elseif key == 28 then
  82.     --End should not be here!!
  83. break
  84. end --End should be here!!
  85. end
  86. end
  87. term.clear()
  88.  
  89. --Conditions
  90. if nOption  == 1 then
  91. shell.run(".FoxOS/.menu")
  92. elseif nOption == 2 then
  93. shell.run(".FoxOS/.lua")
  94. elseif nOption == 3 then
  95. shell.run(".FoxOS/.monitors")
  96. elseif nOption == 4 then
  97. shell.run(".FoxOS/.mkdir")
  98. elseif nOption == 5 then
  99. shell.run(".FoxOS/.copy")
  100. elseif nOption == 6 then
  101. shell.run(".FoxOS/.move")
  102. elseif nOption == 7 then
  103. shell.run(".FoxOS/.rm")
  104. elseif nOption == 8 then
  105. shell.run(".FoxOS/.ie")
  106. else
  107. shell.run(".FoxOS/.what")
  108. end
Add Comment
Please, Sign In to add comment