Advertisement
FeodorKekovich

MultiRadar (Computronics)

Feb 3rd, 2017
614
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.43 KB | None | 0 0
  1. local a=require('component')local b=require('term')local c=require('event')local d=require('serialization')local e=require('filesystem')local f=require('computer')local g='/multiradar/'local h=a.gpu;local i,j=h.getResolution()local k,l=30,24;local m={players={},chatBoxPower=false,userScriptIsOn=false}local n=true;local o={frame=0x00949E,red=0xFF0000,gray=0x474747,white=0xFFFFFF,background=0x000000,text=0x00FFFF}local p={'CLEAR','ON','OFF','[Скрипт пользователя]','x','[ ДА ]','[ НЕТ ]'}function gui()screen='main'local q=4;h.setResolution(k,l)h.setBackground(o.background)b.clear()h.setForeground(o.text)h.set(5,2,'Радаров:    Спалились:')for r in pairs(m.players)do h.set(2,q,'> '..r)q=q+1 end;h.set(5,22,p[1])h.set(19,22,p[2])h.set(22,22,p[3])h.setForeground(o.gray)h.set(1,l,p[4])h.setForeground(o.frame)h.fill(1,1,k,1,'─')h.fill(1,3,k,1,'═')h.fill(1,1,1,l-2,'│')h.fill(k,1,1,l-2,'│')h.fill(4,l-3,l,1,'═')h.fill(4,l-1,l,1,'═')h.set(13,l-2,'CHAT:')h.set(1,1,'┌')h.set(k,1,'┐')h.set(1,3,'╞')h.set(k,3,'╡')h.set(1,l-2,'└')h.set(2,l-2,'─')h.set(3,l-2,'╢')h.set(3,l-3,'╔')h.set(3,l-1,'╚')h.set(k,l-2,'┘')h.set(k-1,l-2,'─')h.set(k-2,l-2,'╟')h.set(k-2,l-3,'╗')h.set(k-2,l-1,'╝')h.set(11,l-2,'│')h.setForeground(o.red)h.set(13,2,#radars..' ')h.set(k,l,p[5])end;function link(s,t,u)f.beep(1500)h.setForeground(o.red)h.set(t,u,p[s])os.sleep(0.3)end;function clicker(v,v,w,x)if w==k and x==l then link(5,k,l)n=false elseif w>=5 and w<=9 and x==22 then link(1,5,22)m.players={}conf_S()gui()elseif w>=19 and w<=20 and x==22 then link(2,19,22)m.chatBoxPower=true;chatBox('Оповещения в чат включены!')conf_S()gui()elseif w>=22 and w<=24 and x==22 then link(3,22,22)chatBox('Оповещения в чат выключены!')m.chatBoxPower=false;conf_S()gui()elseif w>=1 and w<=21 and x==l then link(4,1,l)userScript(true)elseif w>=5 and w<=10 and x==14 and screen=='userScript'then link(6,5,14)m.userScriptIsOn=true;conf_S()gui()elseif w>=19 and w<=25 and x==14 and screen=='userScript'then link(7,19,14)m.userScriptIsOn=false;conf_S()gui()end end;function userScript(gui)if gui then screen='userScript'h.setForeground(o.gray)h.fill(2,4,28,17,' ')h.set(5,6,'Запускает ВАШ скрипт,')h.set(5,7,'расположенный в файле')h.set(4,9,'при обнаружении нового')h.set(12,10,'игрока.')h.setForeground(o.text)h.set(3,8,g..'userscript.lua')h.set(5,12,'Активировать функцию?')h.set(5,14,p[6])h.set(19,14,p[7])else if m.userScriptIsOn then pcall(loadfile(g..'userscript.lua'))end end end;function chatBox(y)if a.isAvailable('chat_box')and m.chatBoxPower then local z=a.chat_box;z.setName('§r§3 MultiRadar §7§o')z.say(y)elseif not a.isAvailable('chat_box')then h.set(2,l-4,'Ошибка: чат бокс не найден!')os.sleep(1)end end;function connect()radars={}for A in pairs(a.list('radar'))do table.insert(radars,A)end;h.setForeground(o.red)h.set(13,2,#radars..' ')end;function connector(v,v,B)if B=='radar'then connect()end end;function createDir()e.makeDirectory(g)local C=io.open(g..'userscript.lua','w')C:flush()C:close()end;function conf_S()local C=io.open(g..'config.cfg','w')C:write(d.serialize(m,false))C:flush()C:close()end;function conf_R()local C=io.open(g..'config.cfg','r')m=d.unserialize(C:read(e.size(g..'config.cfg')))C:close()end;function catched(D)m.players[D]=true;f.beep(1000)f.beep(1500)userScript(false)conf_S()if a.isAvailable('chat_box')then chatBox('§4'..D..'§7 спалился!')end end;function check()if#radars>0 then for E=1,#radars do local check=a.proxy(radars[E]).getPlayers()for F=1,#check do local D=check[F].name;if m.players[D]==nil then catched(D)gui()end end end end end;function run()if not e.exists(g)then createDir()conf_S()else conf_R()end;c.listen('component_added',connector)c.listen('component_removed',connector)c.listen('touch',clicker)connect()gui()while n do h.setResolution(k,l)pcall(check)os.sleep(0.1)end;exit()end;function start()if h.maxDepth()<=4 then f.beep(1500)print('CheckPlayer: Ошибка! Глубина цвета 4 и ниже не поддерживается! Наобходима видеокарта и монитор 3 уровня.')else run()end end;function exit()conf_S()c.ignore('touch',clicker)c.ignore('component_added',connector)c.ignore('component_removed',connector)b.clear()h.setForeground(o.white)h.setResolution(i,j)end;function c.shouldInterrupt()return false end;start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement