Advertisement
Guest User

rosv001

a guest
Jul 25th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.97 KB | None | 0 0
  1. --save as .menu in main dir
  2. function clear()
  3.     term.clear()
  4.     term.setCursorPos(1, 1)
  5. end
  6.  
  7. function printCentred (y,s)
  8.     local x = math.floor((w - string.len(s)) /2)
  9.     term.setCursorPos(x, y)
  10.     term.clearLine()
  11.     term.write(s)
  12. end
  13.  
  14. local choose = 1
  15. --Menu
  16. local function drawMenu()
  17.     clear()
  18.     term.write("---Rauten Os v.001---")
  19. term.setCursorPos(1, 2)
  20. shell.run("id")
  21.    
  22.     term.setCursorPos(w-11,1)
  23.     if choose == 1 then
  24.         term.write("Desktop")
  25.     elseif choose == 2 then
  26.         term.write("Programs")
  27.     elseif choose == 3 then
  28.         term.write("Shutdown")
  29.     elseif choose == 4 then
  30.         term.write("Uninstall")
  31.     else
  32.         end
  33. end
  34.  
  35. --UI
  36.  
  37. term.clear()
  38. local function drawFrontend()
  39.     printCentred(math.floor(h/2) - 3, "")
  40.     printCentred(math.floor(h/2) - 2, "Menu")
  41.     printCentred(math.floor(h/2) - 1, "")
  42.     printCentred(math.floor(h/2) + 0, ((choose == 1) and "[ Command ]") or "Command")
  43.     printCentred(math.floor(h/2) + 1, ((choose == 2) and "[ Promgrams ]") or "Programs"
  44.     printCentred(math.floor(h/2) + 2, ((choose == 3) and "[ Shutdown ]") or "Shutdown"
  45.     printCentred(math.floor(h/2) + 3, ((choose == 4) and "[ Uninstall ]") or "Unsinstall"
  46.     printCentred(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 choose > 1 then
  60.                 choose = choose - 1
  61.                 drawMenu()
  62.                 drawFrontend()
  63.             end
  64.         elseif key == 31 or key == 208 then
  65.         if choose < 4 then
  66.             choose = choose +1
  67.             drawMenu()
  68.             drawFrontend()
  69.         end
  70.         elseif key == 28 then
  71.         break
  72. end
  73. end
  74. endterm.clear()
  75.  
  76. --Events
  77. if choose == 1 then
  78.     shell.run("ros/.command")
  79. elseif choose == 2 then
  80.     shell.rn("ros/.programs")
  81. elseif choose == 3 then
  82.     shell.run("shutdown")
  83. else
  84.     shell.run("ris/.uninstall")
  85. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement