Advertisement
Z1maV1

about

May 8th, 2024
970
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.44 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.0 // ")
  18. term.setCursorPos(1,2)
  19. shell.run("id")
  20.  
  21.    term.setCursorPos(w-11,1)
  22. if nOption == 1 then
  23.    term.write("Back")
  24. else
  25. end
  26.  
  27. end
  28.  
  29. --GUI
  30. term.clear()
  31. local function drawFrontend()
  32.    printCentered( math.floor(h/2) - 3, "")
  33.    printCentered( math.floor(h/2) - 2, "About" )
  34.    printCentered( math.floor(h/2) - 1, "")
  35.    printCentered( math.floor(h/2) + 0, "Name  : DiamondOS")
  36.    printCentered( math.floor(h/2) + 1, "Manu. : LINC     ")
  37.    printCentered( math.floor(h/2) + 2, "Vers. : 1.2.0    ")
  38.    printCentered( math.floor(h/2) + 3, "")
  39.    printCentered( math.floor(h/2) + 4, ((nOption == 1) and "[   Back   ]") or " Back" )
  40. end
  41.  
  42. --Display
  43. drawMenu()
  44. drawFrontend()
  45.  
  46. while true do
  47.     local e,p = os.pullEvent("key")
  48.         if p == keys.up then
  49.             if nOption > 1 then
  50.                 nOption = nOption - 1
  51.                 drawMenu()
  52.                 drawFrontend()
  53.             end
  54.         elseif p == keys.down then
  55.             if nOption < 1 then
  56.                 nOption = nOption + 1
  57.                 drawMenu()
  58.                 drawFrontend()
  59.             end
  60.         elseif p == keys.enter then
  61.             break
  62.         end
  63. end
  64. term.clear()
  65.  
  66. --Conditions
  67. if nOption  == 1 then
  68. shell.run("/bin/main")
  69. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement