Advertisement
markov2019

online

Jun 21st, 2021 (edited)
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.11 KB | None | 0 0
  1. local ColorAdmin=0xFF0000
  2. local ColorTrueMod=0x0000FF
  3. local ColorMod=0xFF0000
  4. local ColorHelper=0x33CC00
  5.  
  6. local PSY={}
  7. local admins={}
  8. local truemoderators={}
  9. local moderators={}
  10. local helpers={}
  11.  
  12. local computer = require("computer")
  13. local term = require("term")
  14. local event = require("event")
  15. local serialization = require('serialization')
  16. local fs = require("filesystem")
  17. local component = require("component")
  18. local gpu = component.gpu
  19. local glass = component.openperipheral_bridge
  20. local running=true
  21. xresolution=60
  22. yresolution=30
  23. gpu.setResolution(xresolution,yresolution) gpu.setBackground(0x000000) gpu.setForeground(0xFFFFFF) gpu.fill(1,1,xresolution,yresolution," ")
  24. gpu.set((xresolution/2-(string.len("Online"))/2),2,"Онлайн")
  25. status1=" online" status2=" offline"
  26.  
  27. function readLists()
  28. if fs.exists("/Status/PSY.txt") then
  29. local file = io.open("/Status/PSY.txt", "r")
  30. local data = file:read("*a")
  31. PSY = serialization.unserialize(data)
  32. file:close()
  33. end
  34. if fs.exists("/Status/Admins.txt") then
  35. local file = io.open("/Status/Admins.txt", "r")
  36. local data = file:read("*a")
  37. admins = serialization.unserialize(data)
  38. file:close()
  39. end
  40. if fs.exists("/Status/TrueModerators.txt") then
  41. local file = io.open("/Status/TrueModerators.txt", "r")
  42. local data = file:read("*a")
  43. truemoderators = serialization.unserialize(data)
  44. file:close()
  45. end
  46. if fs.exists("/Status/Moderators.txt") then
  47. local file = io.open("/Status/Moderators.txt", "r")
  48. local data = file:read("*a")
  49. moderators = serialization.unserialize(data)
  50. file:close()
  51. end
  52. if fs.exists("/Status/Helpers.txt") then
  53. local file = io.open("/Status/Helpers.txt", "r")
  54. local data = file:read("*a")
  55. helpers = serialization.unserialize(data)
  56. file:close()
  57. end
  58. end
  59.  
  60. function writeLists()
  61. local file = io.open("/Status/PSY.txt", "w")
  62. local data = serialization.serialize(PSY)
  63. file:write(data)
  64. file:close()
  65. local file = io.open("/Status/Admins.txt", "w")
  66. local data = serialization.serialize(admins)
  67. file:write(data)
  68. file:close()
  69. local file = io.open("/Status/TrueModerators.txt", "w")
  70. local data = serialization.serialize(truemoderators)
  71. file:write(data)
  72. file:close()
  73. local file = io.open("/Status/Moderators.txt", "w")
  74. local data = serialization.serialize(moderators)
  75. file:write(data)
  76. file:close()
  77. local file = io.open("/Status/Helpers.txt", "w")
  78. local data = serialization.serialize(helpers)
  79. file:write(data)
  80. file:close()
  81. end
  82.  
  83. readLists()
  84.  
  85. function inserting(com)
  86. a=com
  87. if string.find(a,"Admin") ~= nil then b=string.gsub(a,"Admin","") table.insert(admins,1,b) gpu.fill(1,5,xresolution,yresolution," ")
  88. elseif string.find(a,"PSY") ~= nil then b=string.gsub(a,"PSY","") table.insert(PSY,1,b) gpu.fill(1,5,xresolution,yresolution," ")
  89. elseif string.find(a,"TrueMod") ~= nil then b=string.gsub(a,"TrueMod","") table.insert(truemoderators,1,b) gpu.fill(1,5,xresolution,yresolution," ")
  90. elseif string.find(a,"Mod") ~= nil then b=string.gsub(a,"Mod","") table.insert(moderators,1,b) gpu.fill(1,5,xresolution,yresolution," ")
  91. elseif string.find(a,"Helper") ~= nil then b=string.gsub(a,"Helper","") table.insert(helpers,1,b) gpu.fill(1,5,xresolution,yresolution," ")
  92. elseif string.find(a,"RemoveP") ~= nil then b=string.gsub(a,"RemoveP","") for P=1, #PSY do if PSY[P]==b then table.remove(PSY,P) gpu.fill(1,4,xresolution,yresolution," ") end end
  93. elseif string.find(a,"RemoveA") ~= nil then b=string.gsub(a,"RemoveA","") for admin=1, #admins do if admins[admin]==b then table.remove(admins,admin) gpu.fill(1,5,xresolution,yresolution," ") end end
  94. elseif string.find(a,"RemoveT") ~= nil then b=string.gsub(a,"RemoveT","") for truemod=1, #truemoderators do if truemoderators[truemod]==b then table.remove(truemoderators,truemod) gpu.fill(1,5,xresolution,yresolution," ") end end
  95. elseif string.find(a,"RemoveM") ~= nil then b=string.gsub(a,"RemoveM","") for mod=1, #moderators do if moderators[mod]==b then table.remove(moderators,mod) gpu.fill(1,5,xresolution,yresolution," ") end end
  96. elseif string.find(a,"RemoveH") ~= nil then b=string.gsub(a,"RemoveH","") for help=1, #helpers do if helpers[help]==b then table.remove(helpers,help) gpu.fill(1,5,xresolution,yresolution," ") end end end
  97. end
  98.  
  99. function list(_,_,nick,_,com)
  100. if com == "STOP" then running=false
  101. elseif com ~= nil and com ~="STOP" then inserting(com) end
  102. end
  103.  
  104. function Draw(color,group,statusnumber,y)
  105. if y==a then linenumber=a elseif y==t then linenumber=t elseif y==m then linenumber=m elseif y==h then linenumber=h elseif y==p then linenumber=p end
  106. gpu.setForeground(0xFFFFFF)
  107. gpu.set(1,linenumber,'[')
  108. gpu.set(string.len(group)+2,linenumber,']')
  109. gpu.setForeground(color)
  110. gpu.set(2,linenumber,group)
  111. gpu.setForeground(0xFFFFFF)
  112. gpu.set(string.len(group)+4,linenumber,'- ' .. name)
  113. if statusnumber==1 then gpu.setForeground(0x00FF00) gpu.set(xresolution-string.len(status1),linenumber,status1) else gpu.setForeground(0x1a1a1a) gpu.set(xresolution-string.len(status2),linenumber,status2) end
  114. end
  115. while running do
  116. p=4 a=p+#PSY t=p+#admins+#PSY m=p+#admins+#truemoderators+#PSY h=p+#admins+#truemoderators+#moderators+#PSY
  117. event.listen("glasses_chat_command",list)
  118. for i = 1, #PSY do
  119. name=PSY
  120. p=p+1
  121. if computer.addUser(name) ~= nil then Draw(ColorAdmin,'PSY',1,p) else Draw(ColorAdmin,'PSY',0,p) end computer.removeUser(name)
  122. end
  123. for i = 1, #admins do
  124. name=admins
  125. a=a+1
  126. if computer.addUser(name) ~= nil then Draw(ColorAdmin,'Admin',1,a) else Draw(ColorAdmin,'Admin',0,a) end computer.removeUser(name)
  127. end
  128. for i = 1, #truemoderators do
  129. name=truemoderators
  130. t=t+1
  131. if computer.addUser(name) ~= nil then Draw(ColorTrueMod,'TrueMod',1,t) else Draw(ColorTrueMod,'TrueMod',0,t) end computer.removeUser(name)
  132. end
  133. for i = 1, #moderators do
  134. name=moderators
  135. m=m+1
  136. if computer.addUser(name) ~= nil then Draw(ColorMod,'Mod',1,m) else Draw(ColorMod,'Mod',0,m) end computer.removeUser(name)
  137. end
  138. for i = 1, #helpers do
  139. name=helpers
  140. h=h+1
  141. if computer.addUser(name) ~= nil then Draw(ColorHelper,'Helper',1,h) else Draw(ColorHelper,'Helper',0,h) end computer.removeUser(name)
  142. end
  143. os.sleep(0.5)
  144. end
  145. gpu.setResolution(110,55) gpu.setBackground(0x262626) gpu.setForeground(0x00FF00) gpu.fill(1,1,110,55," ") term.setCursor(1,1)
  146. writeLists()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement