Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Функции обработки
- function explode(div,str)
- if (div=='') then return false end
- local pos,arr = 0,{}
- for st,sp in function() return string.find(str,div,pos,true) end do
- table.insert(arr,string.sub(str,pos,st-1))
- pos = sp + 1
- end
- table.insert(arr,string.sub(str,pos))
- return arr
- end
- function rgb2hex(r, g, b)
- return r*65536+g*256+b
- end
- --Цвета
- local colorPage = rgb2hex(211,211,211)
- local white = rgb2hex(255,255,255)
- local black = rgb2hex(0,0,0)
- local ocean = rgb2hex(123,124,233)
- local fiol = rgb2hex(160,37,136)
- local red = rgb2hex(211,8,12)
- local pink = rgb2hex(255,0,255)
- local lime = rgb2hex(150,222,111)
- local blue = rgb2hex(0,0,222)
- local green = rgb2hex(0,128,0)
- local yellow = rgb2hex(255,215,0)
- local darkorange = rgb2hex(255,140,0)
- --Округление числа после запятой до определенного знака floor_to_step(42346.12345678,0.01) -> 42346.12
- function floor_to_step(what,step)
- return math.floor(what/step) * step
- end
- --Наследование классов
- function extended (child, parent)
- setmetatable(child,{__index = parent})
- end
- local component = require('component')
- local event = require("event")
- local side = require("sides")
- local term = require("term")
- local computer = require("computer")
- local serial = require("serialization")
- local modem = component.modem
- local g = component.gpu
- --local chat = component.chat_box
- local buffer = require("doubleBuffering")
- local image = require("image")
- local GUI = require("GUI")
- local shell = require("shell")
- local unicode = require("unicode")
- local LSR = {}
- -- Глобальный класс для управления МЕ системой
- function LSR:new()
- -- свойства
- local obj= {}
- -- obj.firstName = fName
- -- obj.lastName = lName
- --obj.distance = chat.getDistance()
- obj.Name = "Skynet"
- obj.colorName = "red"
- obj.prefix = "SmartHome"
- obj.colors = {
- -- Символ § - ALT + 0,1,6,7
- ["black"] = "§0",
- ["blue"] = "§1",
- ["green"] = "§2",
- ["ocean"] = "§3",
- ["red"] = "§4",
- ["fiol"] = "§5",
- ["yellow"] = "§6",
- ["gray"] = "§7",
- ["darkgray"] = "§8",
- ["lightblue"] = "§9",
- ["default"] = "§3"
- }
- -- Установить свойство
- function obj:setVar(key,val)
- self[key] = val
- return self[key]
- end
- -- Отправить сообщение
- -- function obj:say(msg)
- -- local m = chat.say(self.colors[self.colorName]..self.Name..self.colors["gray"]..": "..msg,self.distance)
- -- return m
- -- end
- --Возвращаем объект МЕ со всеми методами и свойствами! использование в коде local me = ME:new()
- setmetatable(obj, self)
- self.__index = self
- return obj
- end
- --Переменные
- local mainContainer = GUI.fullScreenContainer()
- local content
- local window
- local header
- local page
- local modal
- local dateInput
- local nickInput
- local Filters = {}
- local F = {
- count = 600
- }
- local text
- local button_logs
- local button_ls
- local button_chat
- local button_command
- local button_filters
- local logs = ""
- --Константы
- local TERMINALS = {["a87ed872-c777-4544-9a28-0733767bbfb8"] = 1, ["ecdf5459-2f7a-4a5e-afd6-ed618c34f549"] = 1, ["e97d829b-67ce-4b2c-9db0-04ed15443749"] = 1}
- -- function event.shouldInterrupt()
- -- return false
- -- end
- -- if event.interruptingEnabled then
- -- event.interruptingEnabled = false
- -- end
- ----------------------
- -----Функцианал-----
- function waiting(message,func)
- loading = mainContainer:addChild(GUI.container(20,9,40,1))
- loading:addChild(GUI.panel(1,1,loading.width,loading.height,rgb2hex(255,255,255)))
- local textBox = loading:addChild(GUI.textBox(1, 1, loading.width, loading.height,rgb2hex(255,255,255), rgb2hex(0,0,0), {}, 1, 1, 0))
- table.insert(textBox.lines, {text = message, color = 0x880000})
- textBox:setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER,GUI.ALIGNMENT_VERTICAL_CENTER)
- loading:drawOnScreen(true)
- func()
- loading:remove()
- mainContainer:drawOnScreen(true)
- end
- function getLogs()
- local res = ""
- pcall(function() for chunk in require("internet").request('http://minecraft.graycode.ru/app/lsreader/server/getLogs.php',Filters) do res = res..chunk end end)
- return table.fromString(res)
- end
- function getRawLogs()
- local res = ""
- pcall(function() for chunk in require("internet").request('http://minecraft.graycode.ru/app/lsreader/server/getLogs.php',Filters) do res = res..chunk end end)
- return res
- end
- function floor_to_step(what,step)
- return math.floor(what/step) * step
- end
- function clearContent()
- content:removeChildren()
- content:addChild(GUI.panel(1,1,content.width,content.height,black))
- end
- function getTab(n)
- clearContent()
- if n == 1 then
- Filters.chat = nil
- Filters.commands = nil
- Filters.ls = nil
- waiting("Загрузка...", function() logs = getLogs() end);
- drawTextBox()
- for i = 1, #logs do
- table.insert(text.lines, logs[i][6])
- end
- button_logs.pressed = true
- button_ls.pressed = false
- button_chat.pressed = false
- button_command.pressed = false
- elseif n == 2 then
- Filters.ls = true
- Filters.chat = nil
- Filters.commands = nil
- --GUI.alert(Filters)
- waiting("Загрузка...", function() logs = getLogs() end);
- drawTextBox()
- for i = 1, #logs do
- table.insert(text.lines, logs[i][1].." "..logs[i][2].." /"..logs[i][3].." "..logs[i][4])
- end
- button_logs.pressed = false
- button_ls.pressed = true
- button_chat.pressed = false
- button_command.pressed = false
- elseif n == 3 then
- Filters.chat = true
- Filters.commands = nil
- Filters.ls = nil
- waiting("Загрузка...", function() logs = getLogs() end);
- drawTextBox()
- for i = 1, #logs do
- if logs[i][3] == "l" then
- table.insert(text.lines, logs[i][1].." ".."[Мод.чат]".." "..logs[i][2]..": "..logs[i][4])
- else
- table.insert(text.lines, logs[i][1].." "..logs[i][3].." "..logs[i][2]..": "..logs[i][4])
- end
- end
- button_logs.pressed = false
- button_ls.pressed = false
- button_chat.pressed = true
- button_command.pressed = false
- elseif n == 4 then
- Filters.commands = true
- Filters.chat = nil
- Filters.ls = nil
- waiting("Загрузка...", function() logs = getLogs() end);
- drawTextBox()
- for i = 1, #logs do
- table.insert(text.lines, logs[i][1].." "..logs[i][2].." /"..logs[i][3].." "..logs[i][4])
- end
- button_logs.pressed = false
- button_ls.pressed = false
- button_chat.pressed = false
- button_command.pressed = true
- else
- end
- end
- -----Draw функции-----
- function drawTextBox()
- text = nil
- text = content:addChild(GUI.textBox(1,2,content.width,content.height,black, white, {}, 1, 2,0))
- text.scrollBarEnabled = true
- end
- function drawModal()
- if modal then
- modal = nil
- end
- if g.getResolution() > 80 then
- modal = mainContainer:addChild(GUI.container(mainContainer.width/2-15,mainContainer.height/2-10,30,20))
- else
- modal = mainContainer:addChild(GUI.container(25,5,30,20))
- end
- modal:addChild(GUI.panel(1,1,modal.width,modal.height, fiol))
- if Filters.date then
- dateInput = modal:addChild(GUI.input( 1, 2, 30, 3, white, black, colorPage, white, black, nil, Filters.date))
- else
- dateInput = modal:addChild(GUI.input( 1, 2, 30, 3, white, black, colorPage, white, black, nil, "дд-мм-гггг"))
- end
- if Filters.nick then
- nickInput = modal:addChild(GUI.input( 1, 6, 30, 3, white, black, colorPage, white, black, nil, Filters.nick))
- else
- nickInput = modal:addChild(GUI.input( 1, 6, 30, 3, white, black, colorPage, white, black, nil, "Ник"))
- end
- local reset = modal:addChild(GUI.button(1,modal.height-5, 30, 3, blue, white, white,blue, "Сбросить"))
- reset.onTouch = function()
- Filters.date = nil
- Filters.nick = nil
- modal:remove()
- end
- local button = modal:addChild(GUI.button(1,modal.height-2, 30, 3, blue, white, white,blue, "ОК"))
- button.onTouch = function()
- if #dateInput.text >0 then
- Filters.date = dateInput.text
- end
- if #nickInput.text >0 then
- Filters.nick = nickInput.text
- end
- modal:remove()
- end
- end
- function init()
- LSR = LSR:new() -- инициализация чат модуля
- --LSR:say("Модуль чата активирован.")
- mainContainer:addChild(GUI.panel(1, 1, mainContainer.width, mainContainer.height, colorPage))
- local menu = mainContainer:addChild(GUI.container(1,1,mainContainer.width,3))
- button_logs = menu:addChild(GUI.button(1,1, 20, 3, white, black, black,white, "ЛОГИ"))
- button_logs.switchMode = true
- button_logs.onTouch = function()
- getTab(1)
- end
- button_ls = menu:addChild(GUI.button(21,1, 20, 3, white, black, black,white, "ЛС"))
- button_ls.switchMode = true
- button_ls.onTouch = function()
- getTab(2)
- end
- button_chat = menu:addChild(GUI.button(41,1, 20, 3, white, black, black,white, "Чат"))
- button_chat.switchMode = true
- button_chat.onTouch = function()
- getTab(3)
- end
- button_command = menu:addChild(GUI.button(60,1, 20, 3, white, black, black,white, "КОМАНДЫ"))
- button_command.switchMode = true
- button_command.onTouch = function()
- getTab(4)
- end
- if g.getResolution() > 80 then
- button_filters = menu:addChild(GUI.button(menu.width-19,1, 20, 3, white, ocean, ocean,white, "Фильтры"))
- else
- button_filters = menu:addChild(GUI.button(menu.width-2,1, 3, 3, white, ocean, ocean,white, "Ф"))
- end
- button_filters.onTouch = function()
- drawModal()
- --waiting("Загрузка...", function() logs = getRawLogs() end);
- --GUI.alert(logs)
- end
- content = mainContainer:addChild(GUI.container(1,4,mainContainer.width,mainContainer.height-3))
- content:addChild(GUI.panel(1,1,content.width,content.height,black))
- -- local exitButton = mainContainer:addChild(GUI.button( 2, mainContainer.height-3, 15, 3, rgb2hex(255,255,255), black, rgb2hex(0,0,0), white, "Выйти в Shell" ))
- -- exitButton.onTouch = function()
- -- g.setBackground(0x000000)
- -- term.clear()
- -- g.setForeground(0xffffff)
- -- g.set(1, 1, "")
- -- error("Закрылись", 0)
- -- end
- end
- ----------------------
- --[[ Проверка терминала ]]--
- if not TERMINALS[modem.address] then
- Oops()
- end
- --[[********************]]--
- init()
- mainContainer:drawOnScreen(true)
- mainContainer:startEventHandling()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement