markov2019

Untitled

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