Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --local command_list = {"set text_coordX", "set text_coordY", "set text_color", "set bg_show", "set bg_color", "set bg_opacity", "set max_height", "set adm_nick", "reboot", "del msg", "ban", "unban"}
- local command_list = {}
- local admin = "Syabro"
- local settings = {20, 52, 0xFFFFFF, true, 0x0101FF, 0.5, 10}
- local banned_player = {}
- local text = {}
- local player_banned = false
- local this_command = false
- function newCMD(name, func)
- local s = {name = name, func = func}
- return s
- end
- function addCMD(cmd)
- table.insert(command_list, cmd)
- end
- function findCMD(name)
- for i=1, #command_list do
- if (command_list[i].name == name) then
- table.save(settings,"settings.ch")
- table.save(banned_player,"banned_palyer.ch")
- this_command = true
- return command_list[i]
- end
- end
- end
- function table.save(tbl,filename)
- local fileHandle = fs.open (filename, 'w')
- fileHandle.write (textutils.serialize (tbl))
- fileHandle.close()
- end
- function table.read(filename)
- local fileHandle = fs.open (filename, 'r')
- tbl = textutils.unserialize (fileHandle.readAll())
- fileHandle.close()
- return tbl
- end
- local function init()
- local side={"left","right","back","front","top","bottom"}
- for s=1,6 do
- if peripheral.isPresent(side[s]) then
- if peripheral.getType(side[s]) == "openperipheral_glassesbridge" then
- glass=peripheral.wrap(side[s])
- glass.clear()
- break
- end
- end
- end
- if fs.exists("settings.ch") then
- term.clear()
- term.setCursorPos(1,1)
- print("Read settings file...")
- settings = table.read("settings.ch")
- else
- table.save(settings,"settings.ch")
- end
- if fs.exists("banned_palyer.ch") then
- term.clear()
- term.setCursorPos(1,1)
- print("Read banned player file...")
- banned_player = table.read("banned_palyer.ch")
- else
- table.save(banned_player,"banned_palyer.ch")
- end
- if fs.exists("chCommand") then
- term.clear()
- term.setCursorPos(1,1)
- print("Read command file...")
- os.loadAPI("chCommand")
- else
- term.clear()
- term.setCursorPos(1,1)
- print("Load command file...")
- shell.run("pastebin get 83Sy431N chCommand")
- term.clear()
- term.setCursorPos(1,1)
- print("Read command file...")
- os.loadAPI("chCommand")
- end
- if fs.exists("glass.lua") then
- term.clear()
- term.setCursorPos(1,1)
- print("Read api file...")
- dofile("glass.lua")
- else
- term.clear()
- term.setCursorPos(1,1)
- print("Load api file...")
- shell.run("pastebin get DiYrqfti glass.lua")
- term.clear()
- term.setCursorPos(1,1)
- print("Read api file...")
- dofile("glass.lua")
- end
- addCMD(newCMD("ban",chCommand.ban))
- addCMD(newCMD("unban",chCommand.unban))
- end
- local function commands()
- term.clear()
- term.setCursorPos(1,1)
- print("Setting service started")
- while true do
- _, s_msg, s_nick = os.pullEvent("chat_command")
- --for g_nick, k in pairs(users) do
- if s_nick == admin and string.find(s_msg, " ") ~= nil then
- local msg_arr={}
- for k, v in string.gmatch(s_msg, " ") do
- msg_arr[k] = v
- end
- command_name = msg_arr[1]
- table.remove(msg_arr, 1)
- findCMD(command_name):func(msg_arr)
- end
- --end
- end
- end
- local function chat()
- print("Chat started")
- while true do
- _, c_msg, c_nick = os.pullEvent("chat_command")
- if not this_command then
- for get_ban=1,#banned_player do
- if c_nick==banned_player[get_ban] then
- player_banned=true
- break
- else
- player_banned=false
- end
- end
- if not player_banned then
- glass.clear()
- table.insert(text,textutils.formatTime(os.time(), true).." "..c_nick..": "..tostring(c_msg))
- print(textutils.formatTime(os.time(), true).." "..c_nick..": "..tostring(c_msg))
- if #text>settings[7] then
- table.remove(text, 1)
- end
- printGlassText(glass, text, settings[1], settings[2],settings[3],settings[4],settings[5],settings[6])
- else
- printGlassText(glass, {"You are baned!"}, settings[1], settings[2],settings[3],settings[4],0xFF0000,1,c_nick)
- player_banned=false
- end
- end
- end
- end
- init()
- parallel.waitForAll(commands, chat)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement