Z1maV1

.programs

May 14th, 2022 (edited)
626
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 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("Diamond OS // 1.2.1 //")
  18. term.setCursorPos(1,2)
  19. shell.run("id")
  20.  
  21.    term.setCursorPos(w-11,1)
  22.    if nOption == 1 then
  23.    term.write("Web")
  24. elseif nOption == 2 then
  25.    term.write("Get Files")
  26. elseif nOption == 3 then
  27.    term.write("Send Files")
  28. elseif nOption == 4 then
  29.    term.write("Install")
  30. elseif nOption == 5 then
  31.    term.write("Back")
  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, "Program List" )
  42.    printCentered( math.floor(h/2) - 1, "")
  43.    printCentered( math.floor(h/2) + 0, ((nOption == 1) and "[    Web     ]") or "Web " )
  44.    printCentered( math.floor(h/2) + 1, ((nOption == 2) and "[ Get Files  ]") or "Get Files " )
  45.    printCentered( math.floor(h/2) + 2, ((nOption == 3) and "[ Send Files ]") or "Send Files" )
  46.    printCentered( math.floor(h/2) + 3, ((nOption == 4) and "[  Install   ]") or "Install ")
  47.    printCentered( math.floor(h/2) + 4, ((nOption == 5) and "[    Back    ]") or "Back" )
  48.    printCentered( math.floor(h/2) + 5, "")
  49. end
  50.  
  51. --Display
  52. drawMenu()
  53. drawFrontend()
  54.  
  55. while true do
  56.     local e,p = os.pullEvent("key")
  57.         if p == keys.up then
  58.             if nOption > 1 then
  59.                 nOption = nOption - 1
  60.                 drawMenu()
  61.                 drawFrontend()
  62.             end
  63.         elseif p == keys.down then
  64.             if nOption < 5 then
  65.                 nOption = nOption + 1
  66.                 drawMenu()
  67.                 drawFrontend()
  68.             end
  69.         elseif p == keys.enter then
  70.             break
  71.         end
  72. end
  73. term.clear()
  74.  
  75. --Conditions
  76. if nOption  == 1 then
  77. shell.run("/usr/bin/browser")
  78. elseif nOption == 2 then
  79. shell.run("/usr/bin/getFiles")
  80. elseif nOption == 3 then
  81. shell.run("/usr/bin/sendFiles")
  82. elseif nOption == 4 then
  83. shell.run("/bin/install")
  84. else
  85. shell.run("/bin/main")
  86. end
Advertisement
Add Comment
Please, Sign In to add comment