CCHacker132

MiscBar

Dec 25th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local oterm = term.current()
  2. local osize = {term.getSize()}
  3. local nwindow = window.create(oterm,1,1,osize[1],osize[2]-1,true)
  4. local notifqueue = {}
  5. term.setBackgroundColor(colors.gray)
  6. term.clear()
  7. term.setCursorPos(1,osize[2])
  8. term.setBackgroundColor(colors.red)
  9. term.setTextColor(colors.black)
  10. write('O')
  11.  
  12. local noteHide = false
  13.  
  14. _G.note = {}
  15.  
  16.  
  17. term.redirect(nwindow)
  18. local nsize = {term.getSize()}
  19.  
  20. local function newNotFunc(msg)
  21.     if msg ~= '' then
  22.         table.insert(notifqueue,msg)
  23.     end
  24. end
  25.  
  26. local function getNotFunc()
  27.     return notifqueue
  28. end
  29.  
  30. local function getOpNotFunc()
  31.     return noteHide
  32. end
  33.  
  34. _G.note.getVisible = getOpNotFunc
  35. _G.note.get = getNotFunc
  36. _G.note.send = newNotFunc
  37.  
  38. term.setBackgroundColor(colors.black)
  39. term.clear()
  40.  
  41. local function shellIso()
  42.     shell.run('shell')
  43.     os.shutdown()
  44. end
  45.  
  46. local function clickDet()
  47.     while true do
  48.         local ev = {os.pullEvent('mouse_click')}
  49.         if ev[4] == osize[2] then
  50.             if ev[3] == 1 then
  51.                 os.shutdown()
  52.             end
  53.             if ev[3] == osize[1]-2 then
  54.                 local mxPos = {term.getCursorPos()}
  55.                 if noteHide then
  56.                     noteHide = false
  57.                     paintutils.drawFilledBox(osize[1]-1,osize[2]-2,osize[1]-12,osize[2]-14)
  58.                     term.setCursorPos(mxPos[1],mxPos[2])
  59.                 else
  60.                     noteHide = true
  61.                 end
  62.             end
  63.         end
  64.         if noteHide then
  65.             if notifqueue[13-(ev[4]-(osize[2]-14))] then
  66.                 table.remove(notifqueue,13-(ev[4]-(osize[2]-14)))
  67.             end
  68.         end
  69.     end
  70. end
  71.  
  72. local months = {
  73. ['Jan'] = 1,
  74. ['Feb'] = 2,
  75. ['Mar'] = 3,
  76. ['Apr'] = 4,
  77. ['May'] = 5,
  78. ['Jun'] = 6,
  79. ['Jul'] = 7,
  80. ['Aug'] = 8,
  81. ['Sep'] = 9,
  82. ['Oct'] = 10,
  83. ['Nov'] = 11,
  84. ['Dec'] = 12,
  85.  
  86. }
  87.  
  88. local function barDisp()
  89.     while true do
  90.         sleep()
  91.         local date = os.date()
  92.         local hour = tonumber(string.sub(date,12,13))
  93.         local hourP = false
  94.         if hour > 12 then
  95.             hour = hour - 12
  96.             hourP = true
  97.         end
  98.         local sPos = {oterm.getCursorPos()}
  99.         local sColor = oterm.getTextColor()
  100.         oterm.setCursorPos(osize[1]-22,osize[2])
  101.         oterm.setBackgroundColor(colors.gray)
  102.         oterm.setTextColor(colors.white)
  103.         oterm.write(hour..':')
  104.         oterm.write(string.sub(date,15,16)..' ')
  105.         if hourP then
  106.             oterm.write('PM')
  107.         else
  108.             oterm.write('AM')
  109.         end
  110.         oterm.write('  ')
  111.         oterm.write(months[string.sub(date,5,7)]..'/'..string.sub(date,9,10)..'/'..string.sub(date,-2,-1)..'   ')
  112.         oterm.setCursorPos(osize[1]-2,osize[2])
  113.         if #notifqueue > 0 then
  114.             oterm.setBackgroundColor(colors.red)
  115.             oterm.setTextColor(colors.white)
  116.             oterm.write(string.char(19))
  117.         else
  118.             oterm.setBackgroundColor(colors.lightGray)
  119.             oterm.setTextColor(colors.gray)
  120.             oterm.write('.')
  121.         end
  122.         if noteHide then
  123.             oterm.setBackgroundColor(colors.lightGray)
  124.             for num = 1,13 do
  125.                 oterm.setCursorPos(osize[1]-22,osize[2]-num-1)
  126.                 oterm.write('                      ')
  127.             end
  128.             for num = 1,13 do
  129.                 oterm.setCursorPos(osize[1]-22,osize[2]-num-1)
  130.                 if notifqueue[num] then
  131.                     oterm.write(string.sub(notifqueue[num],1,22))
  132.                 end
  133.             end
  134.         end
  135.         oterm.setTextColor(sColor)
  136.         oterm.setCursorPos(sPos[1],sPos[2])
  137.     end
  138. end
  139.  
  140. parallel.waitForAll(shellIso,clickDet,barDisp)
Add Comment
Please, Sign In to add comment