Guest User

easyinstall

a guest
Jun 16th, 2024
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.26 KB | None | 0 0
  1. local w,h = term.getSize()
  2.  
  3. --Center Text
  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. --Drawmenu
  13.  
  14. local nOption = 1
  15.  
  16. local function drawMenu()
  17.     term.setBackgroundColor(colors.cyan)
  18.     term.clear()
  19.     term.setCursorPos(1,1)
  20.     local logo = paintutils.loadImage("os/.logo")
  21.     paintutils.drawImage(logo, 1, 1)
  22.     term.setBackgroundColor(colors.cyan)
  23.    
  24.     term.setCursorPos(w-11,1)
  25.     if nOption == 1 then
  26.         term.write("INSTALL CC OS")
  27.     elseif nOption == 2 then
  28.         term.write("EXIT SETUP")
  29.     elseif nOption == 3 then
  30.         term.write("SHUTDOWN")
  31.     else
  32.         end
  33. end    
  34.  
  35. --GUI
  36.  
  37. term.clear()
  38. local function drawFrontend()
  39.     printCentered(math.floor(h/2) -3, "")
  40.     printCentered(math.floor(h/2) -2, "SETUP")
  41.     printCentered(math.floor(h/2) -1, "")
  42.     printCentered(math.floor(h/2) + 0, (nOption == 1 and "[ INSTALL CC OS ]") or "INSTALL CC OS")
  43.     printCentered(math.floor(h/2) + 1, (nOption == 2 and "[ EXIT SETUP ]") or "EXIT SETUP")
  44.     printCentered(math.floor(h/2) + 2, (nOption == 3 and "[ SHUTDOWN ]") or "SHUTDOWN")
  45. end
  46.  
  47. --Display
  48.  
  49. drawMenu()
  50. drawFrontend()
  51.  
  52. while true do
  53.     local e,p = os.pullEvent()
  54.         if e == "key" then
  55.             local key = p
  56.             if key == 17 or key == 200 then
  57.            
  58.                 if nOption > 1 then
  59.                     nOption = nOption -1
  60.                     drawMenu()
  61.                     drawFrontend()
  62.                 end
  63.             elseif key == 31 or key == 208 then
  64.                 if nOption < 3 then
  65.                     nOption = nOption +1
  66.                     drawMenu()
  67.                     drawFrontend()
  68.                 end
  69.         elseif key == 28 then
  70.             break
  71. end
  72. end
  73. end
  74.  
  75. term.clear()
  76.  
  77. --Conditions
  78. if nOption == 1 then
  79.     term.clear()
  80.     term.setCursorPos(1,1)
  81.     shell.run("installphase2")    
  82. elseif nOption == 2 then
  83.     term.setBackgroundColor(colors.black)
  84.     term.clear()
  85.     term.setCursorPos(1,1)
  86. elseif nOption == 3 then
  87.     term.clear()
  88.     term.setCursorPos(1,1)
  89.     os.shutdown()
  90. else
  91.     term.setBackgroundColor(colors.black)
  92.     term.clear()
  93.     term.setCursorPos(1,1)
  94. end
Advertisement
Add Comment
Please, Sign In to add comment