SHARE
TWEET

Untitled

a guest Dec 8th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --put these all in folder 'os' (mkdir os)
  2. --make this as .menu
  3. local w,h = term.getSize()
  4. function clearColor()
  5.     setBackgroundColor(colors.black)
  6. end
  7. function printCentered (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. local nOption = 1
  14. mon.write("Penguin OS 1.1 Running...")
  15. local function drawMenu()
  16.     term.clear()
  17.     setCursorPos(1,1)
  18.     term.write("Penguin OS 1.1")
  19.     setCursorPos(1,2)
  20.     term.write("New Features: GUI Updates; Programs option runs an error screen")
  21.     setCursorPos(1,3)
  22.     term.write("because Programs function not yet finished{}")
  23.     setCursorPos(1,4)
  24.     term.write("Report any bugs to Penguinboy887")
  25.     term.setCursorPos(w-11, 1)
  26.     if nOption == 1 then
  27.         term.write("Go to Command Prompt")
  28.     elseif nOption == 2 then
  29.         term.write("List Executable Programs")
  30.     elseif nOption == 3 then
  31.         term.write("Shut the Computer off")
  32.     elseif nOption == 4 then
  33.         term.write("Uninstall")
  34. else
  35. end
  36. local function drawFrontend()
  37. printCentered(math.floor(h/2) - 3, "----")
  38. printCentered(math.floor(h/2) - 2, "Menu")
  39. printCentered(math.floor(h/2) - 1, "----")
  40. printCentered(math.floor(h/2) - 0, ((nOption == 1) and "--{Command}--", or "|Command|")
  41. printCentered(math.floor(h/2) + 1, ((nOption == 2) and "--{Programs}--", or "|Programs|")
  42. printCentered(math.floor(h/2) + 2, ((nOption == 3) and "--{Shutdown}--", or "|Shutdown|")
  43. printCentered(math.floor(h/2) + 3, ((nOption == 4) and "--{Uninstall}--", or "|Uninstall|")
  44. end
  45. setBackgroundColor(colors.green)
  46. drawMenu()
  47. drawFrontend()
  48. while true do
  49.     e,p = os.pullEvent()
  50.     if e == "key" then
  51.         local key = p
  52.         if key == 17 or key == 200 then
  53.             if nOption > 1 then
  54.                 nOption = nOption - 1
  55.                 drawMenu()
  56.                 drawFrontend()
  57.             end
  58.         elseif key == 28 or key == 208 then
  59.             if nOption < 4 then
  60.                 nOption = nOption + 1
  61.                 drawMenu()
  62.                 drawFrontend()
  63.             end
  64.         elseif key = 28 then
  65.             break
  66.         end
  67.     end
  68. end
  69. term.clear()
  70. if nOption == 1 then
  71.     shell.run("os/.command")
  72. elseif nOption == 2 then
  73.     shell.run("os/.programs")
  74. elseif nOption == 3 then
  75.     os.shutdown()
  76. else
  77.     shell.run("os/.uninstall")
  78. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top