Advertisement
Guest User

cctut1

a guest
Feb 2nd, 2015
17,882
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.93 KB | None | 1 0
  1.  
  2. os.pullEvent = os.pullEventRaw
  3.  
  4. local w,h = term.getSize()
  5.  
  6. function printCentered( y,s )
  7.    local x = math.floor((w - string.len(s)) / 2)
  8.    term.setCursorPos(x,y)
  9.    term.clearLine()
  10.    term.write( s )
  11. end
  12.  
  13. local nOption = 1
  14.  
  15. local function drawMenu()
  16.    term.clear()
  17.    term.setCursorPos(1,1)
  18.    term.write("Impending OS Alpha // ")
  19. term.setCursorPos(1,2)
  20. shell.run("id")
  21.  
  22.    term.setCursorPos(w-11,1)
  23.    if nOption == 1 then
  24.    term.write("Command")
  25. elseif nOption == 2 then
  26.    term.write("Programs")
  27. elseif nOption == 3 then
  28.    term.write("Shutdown")
  29. elseif nOption == 4 then
  30.    term.write("Uninstall")
  31. else
  32. end
  33.  
  34. end
  35.  
  36. --GUI
  37. term.clear()
  38. local function drawFrontend()
  39.    printCentered( math.floor(h/2) - 3, "")
  40.    printCentered( math.floor(h/2) - 2, "Start Menu" )
  41.    printCentered( math.floor(h/2) - 1, "")
  42.    printCentered( math.floor(h/2) + 0, ((nOption == 1) and "[ Command  ]") or "Command" )
  43.    printCentered( math.floor(h/2) + 1, ((nOption == 2) and "[ Programs ]") or "Programs" )
  44.    printCentered( math.floor(h/2) + 2, ((nOption == 3) and "[ Shutdown ]") or "Shutdown" )
  45.    printCentered( math.floor(h/2) + 3, ((nOption == 4) and "[ Uninstall]") or " Uninstall" )
  46.    printCentered( math.floor(h/2) + 4, "")
  47. end
  48.  
  49. --Display
  50. drawMenu()
  51. drawFrontend()
  52.  
  53. while true do
  54.  local e,p = os.pullEvent()
  55.  if e == "key" then
  56.   local key = p
  57.   if key == 17 or key == 200 then
  58.  
  59.    if nOption > 1 then
  60.     nOption = nOption - 1
  61.     drawMenu()
  62.     drawFrontend()
  63.    end
  64.   elseif key == 31 or key == 208 then
  65.   if nOption < 4 then
  66.   nOption = nOption + 1
  67.   drawMenu()
  68.   drawFrontend()
  69. end
  70. elseif key == 28 then
  71.     --End should not be here!!
  72. break
  73. end --End should be here!!
  74. end
  75. end
  76. term.clear()
  77.  
  78. --Conditions
  79. if nOption  == 1 then
  80. shell.run("ios/.command")
  81. elseif nOption == 2 then
  82. shell.run("ios/.programs")
  83. elseif nOption == 3 then
  84. os.shutdown()
  85. else
  86. shell.run("ios/.UninstallDialog")
  87. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement