Перейти к содержимому

lLuffy

Пользователи
  • Публикации

    1
  • Зарегистрирован

  • Посещение

Сообщения, опубликованные пользователем lLuffy


  1. Выложу тогда другую, более интересную прогу другого нашего игрока, который не против продвижения программы, но сам бы вряд ли тут написал.

    Программа приятнее на вид, чем то что скинул whiskas, и в неё можно добавлять новых юзеров через очки не выключая саму программу.

     

    $$AdminAlex - добавить
    $$RemoveAAlex - убрать

     

     

    Код.

     

    --Program was created by realanton12345, 2016.
    --All rights reserved.

    local ColorAdmin=0xFF0000
    local ColorTrueMod=0x0000FF
    local ColorMod=0xFF0000
    local ColorHelper=0x33CC00

    local PSY={}
    local admins={}
    local truemoderators={}
    local moderators={}
    local helpers={}

    local computer = require("computer")
    local term = require("term")
    local event = require("event")
    local serialization = require('serialization')
    local fs = require("filesystem")
    local component = require("component")
    local gpu = component.gpu
    local glass = component.openperipheral_bridge
    local running=true
    xresolution=60
    yresolution=30
    gpu.setResolution(xresolution,yresolution) gpu.setBackground(0x000000) gpu.setForeground(0xFFFFFF) gpu.fill(1,1,xresolution,yresolution," ")
    gpu.set((xresolution/2-(string.len("Administration"))/2),2,"Администрация")
    status1=" online" status2=" offline"

    function readLists()
    if fs.exists("/Status/PSY.txt") then
    local file = io.open("/Status/PSY.txt", "r")
    local data = file:read("*a")
    PSY = serialization.unserialize(data)
    file:close()
    end
    if fs.exists("/Status/Admins.txt") then
    local file = io.open("/Status/Admins.txt", "r")
    local data = file:read("*a")
    admins = serialization.unserialize(data)
    file:close()
    end
    if fs.exists("/Status/TrueModerators.txt") then
    local file = io.open("/Status/TrueModerators.txt", "r")
    local data = file:read("*a")
    truemoderators = serialization.unserialize(data)
    file:close()
    end
    if fs.exists("/Status/Moderators.txt") then
    local file = io.open("/Status/Moderators.txt", "r")
    local data = file:read("*a")
    moderators = serialization.unserialize(data)
    file:close()
    end
    if fs.exists("/Status/Helpers.txt") then
    local file = io.open("/Status/Helpers.txt", "r")
    local data = file:read("*a")
    helpers = serialization.unserialize(data)
    file:close()
    end
    end

    function writeLists()
    local file = io.open("/Status/PSY.txt", "w")
    local data = serialization.serialize(PSY)
    file:write(data)
    file:close()
    local file = io.open("/Status/Admins.txt", "w")
    local data = serialization.serialize(admins)
    file:write(data)
    file:close()
    local file = io.open("/Status/TrueModerators.txt", "w")
    local data = serialization.serialize(truemoderators)
    file:write(data)
    file:close()
    local file = io.open("/Status/Moderators.txt", "w")
    local data = serialization.serialize(moderators)
    file:write(data)
    file:close()
    local file = io.open("/Status/Helpers.txt", "w")
    local data = serialization.serialize(helpers)
    file:write(data)
    file:close()
    end

    readLists()

    function inserting(com)
    a=com
    if string.find(a,"Admin") ~= nil then b=string.gsub(a,"Admin","") table.insert(admins,1,b) gpu.fill(1,5,xresolution,yresolution," ")
    elseif string.find(a,"PSY") ~= nil then b=string.gsub(a,"PSY","") table.insert(PSY,1,b) gpu.fill(1,5,xresolution,yresolution," ")
    elseif string.find(a,"TrueMod") ~= nil then b=string.gsub(a,"TrueMod","") table.insert(truemoderators,1,b) gpu.fill(1,5,xresolution,yresolution," ")
    elseif string.find(a,"Mod") ~= nil then b=string.gsub(a,"Mod","") table.insert(moderators,1,b) gpu.fill(1,5,xresolution,yresolution," ")
    elseif string.find(a,"Helper") ~= nil then b=string.gsub(a,"Helper","") table.insert(helpers,1,b) gpu.fill(1,5,xresolution,yresolution," ")
    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
    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
    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
    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
    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
    end

    function list(_,_,nick,_,com)
    if com == "STOP" then running=false
    elseif com ~= nil and com ~="STOP" then inserting(com) end
    end

    function Draw(color,group,statusnumber,y)
    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
    gpu.setForeground(0xFFFFFF)
    gpu.set(1,linenumber,'[')
    gpu.set(string.len(group)+2,linenumber,']')
    gpu.setForeground(color)
    gpu.set(2,linenumber,group)
    gpu.setForeground(0xFFFFFF)
    gpu.set(string.len(group)+4,linenumber,'- ' .. name)
    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
    end
    while running do
    p=4 a=p+#PSY t=p+#admins+#PSY m=p+#admins+#truemoderators+#PSY h=p+#admins+#truemoderators+#moderators+#PSY
    event.listen("glasses_chat_command",list)
    for i = 1, #PSY do
    name=PSY
    p=p+1
    if computer.addUser(name) ~= nil then Draw(ColorAdmin,'PSY',1,p) else Draw(ColorAdmin,'PSY',0,p) end computer.removeUser(name)
    end
    for i = 1, #admins do
    name=admins
    a=a+1
    if computer.addUser(name) ~= nil then Draw(ColorAdmin,'Admin',1,a) else Draw(ColorAdmin,'Admin',0,a) end computer.removeUser(name)
    end
    for i = 1, #truemoderators do
    name=truemoderators
    t=t+1
    if computer.addUser(name) ~= nil then Draw(ColorTrueMod,'TrueMod',1,t) else Draw(ColorTrueMod,'TrueMod',0,t) end computer.removeUser(name)
    end
    for i = 1, #moderators do
    name=moderators
    m=m+1
    if computer.addUser(name) ~= nil then Draw(ColorMod,'Mod',1,m) else Draw(ColorMod,'Mod',0,m) end computer.removeUser(name)
    end
    for i = 1, #helpers do
    name=helpers
    h=h+1
    if computer.addUser(name) ~= nil then Draw(ColorHelper,'Helper',1,h) else Draw(ColorHelper,'Helper',0,h) end computer.removeUser(name)
    end
    os.sleep(0.5)
    end
    gpu.setResolution(110,55) gpu.setBackground(0x262626) gpu.setForeground(0x00FF00) gpu.fill(1,1,110,55," ") term.setCursor(1,1)
    writeLists()

     

     

    Скрин

     

    0ce6db7059.png

    Добавил пару ников с вашего форума)

     

    • Нравится 1
    • Спасибо 1
    • Ха-ха 1
×
×
  • Создать...