Advertisement
RandomNewbieScripter

Untitled

Nov 11th, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.34 KB | None | 0 0
  1. --Variable
  2. local osVer = "Alpha 1.0"
  3. local w,h = term.getSize()
  4. local brunning = true
  5. local slc = 0
  6. local _mtext = 1
  7. local _mback = 128
  8.  
  9. --Tables
  10. local menu = {
  11.         [""] = {tcol = _mtext; bcol = _mback; x = 1; xx = 7; y = 1; cmd = function() slc = 1 end};
  12.         ["            "] = {tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 2; cmd = function() end};
  13.         [" Programs > "] = {tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 3; cmd = function() end};
  14.         [" Settings > "] = {tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 4; cmd = function() end};
  15.         [" Lua Prompt "] = {tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 5; cmd = function() end};
  16.         [" Quit       "] = {tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 6; cmd = function() term.setBackgroundColor(colors.black) term.setCursorPos(1,1) term.clear() brunning = false end};
  17.         [" Shutdown   "] = {tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 7; cmd = function() os.shutdown() end};
  18.         [" Logoff     "] = {tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 8; cmd = function() end};
  19.         [" Reboot     "] = {tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 9; cmd = function() shell.run("pastebin run ghqk3qWx") end};
  20.         [" Glitch     "] = {tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 10; cmd = function() for i=1, 500 do  print("ERROR") end os.shutdown() end};
  21. }
  22. --Functions
  23. local function tb_Draw()
  24.         term.setCursorPos(1,1)
  25.         term.setBackgroundColor(8)
  26.         term.setTextColor(1)
  27.         term.clearLine()
  28.         print("[Begin]")
  29.         term.setCursorPos(math.floor(w)-#osVer, 1)
  30.         print(osVer)
  31. end
  32.  
  33. local function clear(bcol)
  34.         term.setBackgroundColor(bcol)
  35.         term.clear()
  36. end
  37.  
  38. local function drawMenu()
  39.         for k,v in pairs(menu) do
  40.                 term.setBackgroundColor(v.bcol)
  41.                 term.setTextColor(v.tcol)
  42.                 term.setCursorPos(v.x, v.y)
  43.                 print(k)
  44.         end
  45. end
  46.  
  47. local function menuClick()
  48.         for k,v in pairs(menu) do
  49.                 if      e[1] == "mouse_click" then
  50.                         if e[2] == 1 then
  51.                                 if e[3] >= v.x and e[3] <= v.xx and e[4] == v.y then
  52.                                         v.cmd()
  53.                                         else slc = 0 clear(colors.black) tb_Draw()
  54.                                 end
  55.                         end
  56.                 end
  57.         end
  58. end
  59.  
  60. --Main code
  61. shell.run("clear")
  62. print("Starting...")
  63. textutils.slowPrint("########")
  64. sleep(0.2)
  65. print("Testing ram...")
  66. sleep(0.2)
  67. print("Testing disk...")
  68. sleep(0.2)
  69. print("Testing CPU...")
  70. sleep(0.2)
  71. print("Testing GPU...")
  72. sleep(0.2)
  73. print("Done..")
  74. sleep(0.1)
  75. clear(colors.black)
  76. tb_Draw()
  77. while brunning do
  78. e = {os.pullEvent()}
  79.         if slc == 0 then
  80.                 clear(colors.black)
  81.                 tb_Draw()
  82.                 if      e[1] == "mouse_click" then
  83.                         if e[2] == 1 then
  84.                                 if e[3] >= 1 and e[3] <= 7 and e[4] == 1 then
  85.                                         slc = 1
  86.                                         drawMenu()
  87.                                 end
  88.                         end
  89.                 end
  90.  
  91.         elseif slc == 1 then
  92.                 drawMenu()
  93.                 menuClick()
  94.         end
  95. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement