Advertisement
Dancho

Chaprad.lua

Jul 22nd, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 24.43 KB | None | 0 0
  1. local c = require('component') -- Программа была написана FeodorKekovich
  2. local ser = require('serialization')
  3. local fs = require('filesystem')
  4. local comp = require('computer')
  5. local ev = require('event')
  6. local term = require('term')
  7. local u = require('unicode')
  8. local keyb = require('keyboard')
  9. local g = c.gpu
  10.  
  11. local color, set, fill, resol, backgr, av, uA, rU, clear, rep, sleep, listen, ignore, startTimer, stopTimer, setCur, char, len, ins, rem, sub, key = g.setForeground, g.set, g.fill, g.setResolution, g.setBackground, c.isAvailable, comp.addUser, comp.removeUser, term.clear, string.rep, os.sleep, ev.listen, ev.ignore, ev.timer, ev.cancel, term.setCursor, u.char, u.len, table.insert, table.remove, u.sub, keyb.keys
  12. local wOld, hOld = g.getResolution()
  13. local w, h = 80, 20
  14. local CPmaxPlayers, CPstartX, CPstartY, CPnickWidth = 14, 58, 3, 16
  15. local chatLog = { max = 14, width = 54 }
  16. local colors = { general = 0x6699FF, gray = 0x333333, green = 0x00ff45, text = 0xCCCCCC, white = 0xFFFFFF, red = 0xFF0000, black = 0x000000 }
  17. local configPath, autorunPath = '/.chaprad.cfg', '/.autorun.lua'
  18. local partMass = { 'explode', 'largeexplode', 'hugeexplosion', 'fireworksSpark', 'splash', 'depthsuspend', 'crit', 'magicCrit', 'smoke', 'largesmoke', 'spell', 'instantSpell', 'mobSpell', 'witchMagic', 'dripWater', 'dripLava', 'angryVillager', 'happyVillager', 'note', 'portal', 'enchantmenttable', 'flame', 'lava', 'reddust', 'slime', 'heart', 'cloud', 'snowshovel', 'blockcrack_137_0', 'blockcrack_57_0', 'blockcrack_7_0' }
  19. local partPreset, spawnTimer = 1, 1
  20. local toScan, maxRadarList, chatDelay, scanTimer, doScan, radarChat = 'игроки', 13, 1, 1, false, false
  21. local globalSleep = 0.0001
  22. local screen = 'info'
  23. local work = true
  24.  
  25. local config = { chatBoxName = 'ЧатБокс',
  26.                  chatTextColor = '§7',
  27.                  activeAutorun = false,
  28.                  players = {  },
  29.                  partsPresets = {
  30.                               {{name = false, height = 0, radius = 0, mode = true},
  31.                                {name = false, height = 0, radius = 0, mode = true},
  32.                                {name = false, height = 0, radius = 0, mode = true}},
  33.                               {{name = false, height = 0, radius = 0, mode = true},
  34.                                {name = false, height = 0, radius = 0, mode = true},
  35.                                {name = false, height = 0, radius = 0, mode = true}},
  36.                               {{name = false, height = 0, radius = 0, mode = true},
  37.                                {name = false, height = 0, radius = 0, mode = true},
  38.                                {name = false, height = 0, radius = 0, mode = true}}
  39.                               }
  40.                }
  41.  
  42. function drawGui()
  43.     backgr(colors.black)
  44.     clear()
  45.     resol(w,h)
  46.     drawBox(57,1,24,h,colors.general)
  47.     set(57,18,'├'..rep('─',22)..'┤')
  48.     color(colors.gray)
  49.     fill(58,3,22,1,'─')
  50.     color(colors.text)
  51.     set(58,19,'[+]')
  52.     set(65,2,'Чек-плеер')
  53.     checkPlayer()
  54.     chatBox()
  55. end
  56.  
  57. function chatBox()
  58.     screen = 'chat'
  59.     header(1,'Чатбокс',2)
  60.     if chatAccess then
  61.         setText(9,18,'[rename] [console] [nick] [spam] [kick]',colors.text)
  62.         color(colors.general)
  63.         fill(2,17,54,1,'─')
  64.         set(1,17,'├')
  65.         set(56,17,'┤')
  66.         fill(7,17,1,4,'│')
  67.         set(7,17,'┬')
  68.         set(7,20,'┴')
  69.         fill(2,18,5,2,'|')
  70.         set(3,19,'SAY')
  71.         printChatLog()
  72.     else
  73.         message('Чатбокс не подключен!',29)
  74.     end
  75. end
  76.  
  77. function particles()
  78.     screen = 'parts'
  79.     header(11,'Частицы',2)
  80.     if particleAccess then
  81.         startID = 1    
  82.         selectedPartID = 0
  83.         printScrollMenu(2,4,16,16,partMass,colors.gray)
  84.         for i = 0, 10, 5 do
  85.             drawBox(19,i+5,37,5,colors.gray)
  86.             set(20,i+7,'радиус')
  87.             set(30,i+7,'высота')
  88.             set(44,i+7,'режим')
  89.             color(colors.general)
  90.             set(20,i+8,'[+][-]')
  91.             set(30,i+8,'[+][-]')
  92.             set(52,i+8,'[x]')
  93.         end
  94.         printSpawnList()
  95.     else
  96.         message('Карта эффектов частиц не подключена!',29)
  97.     end
  98. end
  99.  
  100. function radar()
  101.     screen = 'radar'
  102.     header(21,'Радар',3)
  103.     if radarAccess then
  104.         printRadarMenu()
  105.     else
  106.         message('Радар не подключен!',29)
  107.     end
  108. end
  109.  
  110. function settings()
  111.     screen = 'setts'
  112.     header(31,'Конфиг.',2)
  113.     set(3,4,'Автозапуск')
  114.     set(3,6,'[Force Save]')
  115.     printSetts()
  116. end
  117.  
  118. function header(xStart,menu,menuStart)
  119.     set(1,1,'  ',true)
  120.     clearArea(2,1,54,19)
  121.     color(colors.text)
  122.     set(55,2,'x')
  123.     set(3,2,'Чатбокс')
  124.     set(13,2,'Частицы')
  125.     set(24,2,'Радар')
  126.     set(33,2,'Конфиг.')
  127.     drawBox(1,3,56,18,colors.general)
  128.     set(xStart,1,'┌─────────┐')
  129.     set(xStart,2,'│         │')
  130.     set(xStart,3,'┘         └')
  131.     if screen == 'chat' then
  132.         set(1,3,'│')
  133.     end
  134.     set(xStart+menuStart,2,menu)
  135. end
  136.  
  137. function drawBox(x,y,width,height,col)
  138.     color(col)
  139.     fill(x,y,1,height,'│')
  140.     fill(x+width-1,y,1,height,'│')
  141.     set(x,y,'┌'..rep('─',width-2)..'┐')
  142.     set(x,y+height-1,'└'..rep('─',width-2)..'┘')
  143. end
  144.  
  145. function message(text,center)
  146.     screen = 'message'
  147.     local align = 2
  148.     local x, y = (center - len(text)/2) - align, 9
  149.     local textX = x + align
  150.     local width, height = len(text)+align*2, 5
  151.     clearArea(2,4,54,16)
  152.     drawBox(x,y,width,height,colors.gray)
  153.     setText(textX,y+2,text,colors.general)
  154. end
  155.  
  156. function setText(x,y,text,col)
  157.     color(col)
  158.     set(x,y,text)
  159. end
  160.  
  161. function clearArea(x,y,width,height)
  162.     fill(x,y,width,height,' ')
  163. end
  164.  
  165. function conf_S()
  166.     local file = io.open(configPath,'w')
  167.     file:write(ser.serialize(config,false)):flush():close()
  168. end
  169.  
  170. function conf_R()
  171.     local file = io.open(configPath,'r')
  172.     config = ser.unserialize(file:read(fs.size(configPath)))
  173.     file:close()
  174. end
  175.  
  176. function press(act)
  177.     if act == 'lock' then
  178.         ignore('touch',clicker)
  179.         ignore('scroll',clicker)
  180.         ignore('drag',clicker)
  181.         ignore('drop',clicker)
  182.     else
  183.         listen('touch',clicker)
  184.         listen('scroll',clicker)
  185.         listen('drag',clicker)
  186.         listen('drop',clicker)
  187.     end
  188. end
  189.  
  190. function link(bX,bY,button,col)
  191.     setText(bX,bY,button,colors.red)
  192.     sleep(0.1)
  193.     setText(bX,bY,button,col)
  194. end
  195.  
  196. function checkPlayer()
  197.     clearArea(58,4,22,14)
  198.     for i = 1, #config.players do
  199.         local nick = config.players[i]
  200.         local height = i + CPstartY
  201.         local test = uA(nick) rU(nick)
  202.         if len(nick) > CPnickWidth then
  203.             nick = sub(nick,1,CPnickWidth)..'..'
  204.         end
  205.         if test then
  206.             nickColor = colors.general
  207.         else
  208.             nickColor = colors.gray
  209.         end
  210.         setText(CPstartX,height,'> '..nick,nickColor)
  211.         setText(w-1,height,'x',colors.gray)
  212.     end
  213. end
  214.  
  215. function input(x,y,width,col)
  216.     local str, S = '', ''
  217.     local wCorr = width - 4
  218.     setText(x,y,'>>_',col)
  219.     while true do
  220.         evName,_,un,code = ev.pull(0.1)
  221.         if evName == 'key_down' then
  222.             if un ~= nil and un > 0 and code ~= key.tab then
  223.                 if code == key.enter then
  224.                     clearArea(x,y,width,1)
  225.                     return str
  226.                 elseif code == key.back then
  227.                     str = sub(str,1,-2)
  228.                 elseif un == 38 or un == 63 then
  229.                     str = str..u.char(167)
  230.                 else
  231.                     str = str..char(un)
  232.                 end
  233.                 if len(str) >= wCorr then
  234.                     S = sub(str,-wCorr)
  235.                 else
  236.                     S = str
  237.                 end
  238.                 setText(x+2,y,S..'_ ',col)
  239.             end
  240.         elseif evName == 'touch' then
  241.             clearArea(x,y,width,1)
  242.             return false
  243.         end
  244.     end
  245. end
  246.  
  247. function addPlayer()
  248.     local newNick = input(61,19,19,colors.text)
  249.     if newNick then
  250.         if len(newNick) > 0 then
  251.             ins(config.players,newNick)
  252.             checkPlayer()
  253.         end
  254.     end
  255. end
  256.  
  257. function say(frase)
  258.     if frase then
  259.         chat.setName(config.chatBoxName)
  260.         chat.say(config.chatTextColor..frase)
  261.         chatLogging(_,_,'[YOU]',frase)
  262.     end
  263. end
  264.  
  265. function renameChatBox(nName,nColor)
  266.     if nName then
  267.         config.chatTextColor = nColor
  268.         config.chatBoxName = nName
  269.         chat.setName(config.chatBoxName)
  270.     end
  271. end
  272.  
  273. function spam()
  274.     chat.setName('§kqwerty')
  275.     setText(35,18,'[stop]',colors.red)
  276.     while true do
  277.         local eventName = ev.pull(0.001)
  278.         if eventName == 'touch' then
  279.             setText(35,18,'[spam]',colors.text)
  280.             break
  281.         else
  282.             chat.say('§k'..math.random(100)..'qwertyqwertyqwertyqwertyqwerty')
  283.         end
  284.     end
  285. end
  286.  
  287. function longStr()
  288.     local s1, s2 = '', 'лолкекчебурек'
  289.     for i = 1, 2500 do
  290.         s1 = s1..s2
  291.     end
  292.     return s1
  293. end
  294.  
  295. function kick()
  296.     chat.setName('@')
  297.     setText(42,18,'[stop]',colors.red)
  298.     local str = longStr()
  299.     while true do
  300.         local eventName = ev.pull(0.001)
  301.         if eventName == 'touch' then
  302.             setText(42,18,'[kick]',colors.text)
  303.             break
  304.         else
  305.             chat.say('§k'..str)
  306.         end
  307.     end
  308. end
  309.  
  310. function printChatLog()
  311.     if screen == 'chat' then
  312.         for i = 1, #chatLog do
  313.             local y = 17-i
  314.             setText(2,y,subber(chatLog[i],chatLog.width),colors.gray)
  315.         end
  316.     end
  317. end
  318.  
  319. function subber(input,width)
  320.     return input..rep(' ',width-len(input))
  321. end
  322.  
  323. function chatLogging(_,_,speaker,mess)
  324.     if mess:find('!') == 1 then
  325.         prefix = '[G]' cut = 2
  326.     else
  327.         prefix = '' cut = 1
  328.     end
  329.     local str = prefix..''..speaker..': '..sub(mess,cut)
  330.     local mess1 = sub(str,1,chatLog.width)
  331.     local mess2 = sub(str,chatLog.width+1)
  332.     ins(chatLog,1,mess1)
  333.     if len(mess2) > 0 then
  334.         ins(chatLog,1,sub(mess2,1,chatLog.width))
  335.     end
  336.     chatLog[chatLog.max] = nil
  337.     printChatLog()
  338. end
  339.  
  340. function scrollMenu(x,y,width,height,scrollDir,data,col)
  341.     startID = startID + -scrollDir
  342.     if startID <= 0 then
  343.         startID = 1
  344.     end
  345.     if startID >= #data - (height - 1) then
  346.         startID = #data - (height - 1)
  347.     end
  348.     printScrollMenu(x,y,width,height,data,col)
  349. end
  350.  
  351. function printScrollMenu(x,y,width,height,data,col)
  352.     color(col)
  353.     fill(x+width,y,1,height,'│')
  354.     for i = 0, height - 1 do
  355.         local pId = i+startID
  356.         if pId == selectedPartID then
  357.             setCol = colors.general
  358.         else
  359.             setCol = col
  360.         end
  361.         setText(x,y+i,subber(data[pId],width),setCol)
  362.     end
  363.     setText(x+width,y+startID-1,'│',colors.general)
  364. end
  365.  
  366. function printSpawnList()
  367.     setText(20,4,'<  [СТАРТ]    Пресет '..partPreset..'    [СТОП]  >',colors.general)
  368.     for i = 1, 3 do
  369.         local partName = config.partsPresets[partPreset][i].name
  370.         if not partName then
  371.             partName = 'Перетащите сюда частицу...'
  372.             pCol = colors.gray
  373.         else
  374.             pCol = colors.general
  375.         end
  376.         local y = i*5+1
  377.         setText(20,y,subber(partName,35),pCol)
  378.         color(colors.gray)
  379.         set(27,y+2,config.partsPresets[partPreset][i].radius..'  ')
  380.         set(37,y+2,config.partsPresets[partPreset][i].height..'  ')
  381.         set(41,y+2,'[куб][круг]')
  382.         if config.partsPresets[partPreset][i].mode then
  383.             setText(41,y+2,'[куб]',colors.general)
  384.         else
  385.             setText(46,y+2,'[круг]',colors.general)
  386.         end
  387.     end
  388. end
  389.  
  390. function spawn()
  391.     for i = 1, 3 do
  392.         local pName = config.partsPresets[partPreset][i].name
  393.         if pName then
  394.             local radius = config.partsPresets[partPreset][i].radius
  395.             local height = config.partsPresets[partPreset][i].height
  396.             local mode = config.partsPresets[partPreset][i].mode
  397.             if mode then
  398.                 for _= 1 , 2 do
  399.                     p.spawn(tostring(pName),math.random(-radius,radius)-0.5,math.random(-radius,radius)+height,math.random(-radius,radius)-0.5)
  400.                 end
  401.             else
  402.                 for c = 0, 360, 4 do
  403.                     p.spawn(tostring(pName),math.sin(math.rad(c))*radius-0.5,height,math.cos(math.rad(c))*radius-0.5)
  404.                 end
  405.             end
  406.         end
  407.     end
  408. end
  409.  
  410. function printRadarMenu()
  411.     clearArea(2,4,54,16)
  412.     drawBox(33,4,22,3,colors.gray)
  413.     if toScan == 'игроки' then
  414.         xt = 35
  415.     elseif toScan == 'мобы' then
  416.         xt = 44
  417.     elseif toScan == 'айтемы' then
  418.         xt = 52
  419.     end
  420.     set(7,4,'Найденные '..toScan..':    ')
  421.     fill(31,4,1,16,'│')
  422.     fill(35,6,18,1,'─')
  423.     fill(xt,6,1,3,'│')
  424.     set(xt,6,'┬')
  425.     if chatAccess then
  426.         set(32,19,'Оповещения в чат:')
  427.         if radarChat then
  428.             setText(50,19,'[ВКЛ]',colors.general)
  429.         else
  430.             set(50,19,'[ВЫК]')
  431.         end
  432.     end
  433.     color(colors.general)
  434.     set(32,9,'[игроки] [мобы] [айтемы]')
  435.     if doScan then
  436.         set(38,5,'Остановить!!')
  437.     else
  438.         set(38,5,'Сканировать!')
  439.     end
  440. end
  441.  
  442. function scan()
  443.     chatDelay = chatDelay + 1
  444.     if chatDelay > 5 then
  445.         sayTable = {  }
  446.         chatDelay = 1
  447.     end
  448.     if toScan == 'игроки' then
  449.         find = r.getPlayers()
  450.     elseif toScan == 'мобы' then
  451.         find = r.getMobs()
  452.     elseif toScan == 'айтемы' then
  453.         find = r.getItems()
  454.     end
  455.     if screen == 'radar' and doScan then
  456.         clearArea(2,5,29,15)
  457.     end
  458.     for i = 1, #find do
  459.         local y = i + 5
  460.         if toScan == 'айтемы' then
  461.             name = find[i].label
  462.         else
  463.             name = find[i].name
  464.         end
  465.         local dist = '['..tostring(math.floor(find[i].distance))..'m.]'
  466.         if screen == 'radar' and doScan then
  467.             if name == whiteScan then
  468.                 setText(3,y,'ВЫ > '..dist,colors.gray)
  469.             else
  470.                 local str = sub(name,1,21)..' '
  471.                 setText(3,y,str,colors.gray)
  472.                 setText(3+len(str),y,dist,colors.general)
  473.             end
  474.         end
  475.         if radarChat and chatDelay == 5 and name ~= whiteScan then
  476.             ins(sayTable,'§7§o'..name..' §r§l§6'..dist..'§r')
  477.         end
  478.         if i >= maxRadarList then
  479.             break
  480.         end
  481.     end
  482.     if #sayTable > 0 then
  483.         local frase = '§r§4'..toScan..': '..table.concat(sayTable,', ')
  484.         radarChatting(frase)
  485.     end
  486. end
  487.  
  488. function radarChatting(frase)
  489.     chat.setName('§r§9Сканер§7§o')
  490.     chat.say(frase)
  491. end
  492.  
  493. function swich(toSwich)
  494.     if toSwich == 'autorun' then
  495.         if config.activeAutorun then
  496.             config.activeAutorun = false
  497.             fs.remove(autorunPath)
  498.         else
  499.             fs.setAutorunEnabled(true)
  500.             config.activeAutorun = true
  501.             saveAutorun()
  502.         end
  503.     end
  504. end
  505.  
  506. function saveAutorun()
  507.     local scriptPath = debug.getinfo(2,'S').short_src
  508.     local file = io.open(autorunPath,'w')
  509.     file:write('os.sleep(1) os.execute("'..scriptPath..'")'):flush():close()
  510. end
  511.  
  512. function printSetts()
  513.     setText(20,4,'▒▒▒▒',colors.gray)
  514.     if config.activeAutorun then
  515.         setText(22,4,'██',colors.general)
  516.     else
  517.         setText(20,4,'██',colors.gray)
  518.     end
  519. end
  520.  
  521. function chatBoxer()
  522.     while true do
  523.         local frase = input(9,19,47,colors.text)
  524.         if frase then
  525.             say(frase,'§7')
  526.         else
  527.             break
  528.         end
  529.     end
  530. end
  531.  
  532. function clicker(evName,_,curX,curY,scrollDir,touchNick)
  533.     if evName == 'touch' then
  534.         -- setText(45,2,'x:'..curX..','..curY..'  ',colors.gray) -- для теста позиции курсора
  535.         if     curX == 55 and curY == 2 then link(curX,curY,'x',colors.red) work = false
  536.         elseif curX >= 2  and curX <= 10 and curY == 2 then chatBox()
  537.         elseif curX >= 12 and curX <= 20 and curY == 2 then particles()
  538.         elseif curX >= 22 and curX <= 30 and curY == 2 then radar()
  539.         elseif curX >= 32 and curX <= 40 and curY == 2 then settings()
  540.         elseif curX >= 2  and curX <= 6  and curY >= 18 and curY <= 19 and screen == 'chat' then press('lock') link(3,19,'SAY',colors.general) chatBoxer() press()
  541.         elseif curX >= 9  and curX <= 16 and curY == 18 and screen == 'chat' then press('lock') link(9,curY,'[rename]',colors.text) renameChatBox(input(9,19,47,colors.text),'§7') press()
  542.         elseif curX >= 18 and curX <= 26 and curY == 18 and screen == 'chat' then link(18,curY,'[console]',colors.text) renameChatBox('§r§dSERVER§7§o','§d')
  543.         elseif curX >= 28 and curX <= 33 and curY == 18 and screen == 'chat' then link(28,curY,'[nick]',colors.text) renameChatBox('§r§k|:|§r§9'..touchNick..'§r§k|:|§r§7§o','§7')
  544.         elseif curX >= 35 and curX <= 40 and curY == 18 and screen == 'chat' then press('lock') spam() press()
  545.         elseif curX >= 42 and curX <= 47 and curY == 18 and screen == 'chat' then press('lock') kick() press()
  546.         elseif curX >= 58 and curX <= 60 and curY == 19 and #config.players < CPmaxPlayers then press('lock') link(58,curY,'[+]',colors.text) addPlayer() press()
  547.         elseif curX == 79 and curY >= 4  and (curY - 3) <= #config.players then link(79,curY,'x',colors.gray) local plId = curY - 3 rem(config.players,plId) checkPlayer()
  548.         elseif curX >= 2  and curX <= 17 and curY >= 4  and curY <= 19 and screen == 'parts' then dragParts = true selectedPartID = curY + startID - 4 printScrollMenu(2,4,16,16,partMass,colors.gray)
  549.         elseif curX == 20 and curY == 4  and screen == 'parts' then link(20,curY,'<',colors.general) partPreset = partPreset - 1 if partPreset <= 1 then partPreset = 1 end printSpawnList()
  550.         elseif curX == 54 and curY == 4  and screen == 'parts' then link(54,curY,'>',colors.general) partPreset = partPreset + 1 if partPreset >= 3 then partPreset = 3 end printSpawnList()
  551.         elseif curX >= 23 and curX <= 29 and curY == 4  and screen == 'parts' then link(23,curY,'[СТАРТ]',colors.general) stopTimer(spawnTimer) spawnTimer = startTimer(globalSleep,spawn,math.huge)
  552.         elseif curX >= 46 and curX <= 51 and curY == 4  and screen == 'parts' then link(46,curY,'[СТОП]',colors.general) stopTimer(spawnTimer)
  553.         elseif curX >= 34 and curX <= 53 and curY == 5  and screen == 'radar' and not doScan then doScan = true whiteScan = touchNick stopTimer(scanTimer) scanTimer = startTimer(1,scan,math.huge) printRadarMenu()
  554.         elseif curX >= 34 and curX <= 53 and curY == 5  and screen == 'radar' and doScan then doScan = false stopTimer(scanTimer) printRadarMenu()
  555.         elseif curX >= 32 and curX <= 39 and curY == 9  and screen == 'radar' then toScan = 'игроки' link(32,curY,'['..toScan..']',colors.general) printRadarMenu()
  556.         elseif curX >= 41 and curX <= 46 and curY == 9  and screen == 'radar' then toScan = 'мобы' link(41,curY,'['..toScan..']',colors.general) printRadarMenu()
  557.         elseif curX >= 48 and curX <= 55 and curY == 9  and screen == 'radar' then toScan = 'айтемы' link(48,curY,'['..toScan..']',colors.general) printRadarMenu()
  558.         elseif curX >= 50 and curX <= 55 and curY == 19 and screen == 'radar' and chatAccess and not radarChat then radarChat = true radarChatting('Оповещения в чат включены!') setText(50,19,'[ВКЛ]',colors.general)
  559.         elseif curX >= 50 and curX <= 55 and curY == 19 and screen == 'radar' and chatAccess and radarChat then radarChat = false radarChatting('Оповещения в чат выключены...') setText(50,19,'[ВЫК]',colors.gray)
  560.         elseif curX >= 20 and curX <= 23 and curY == 4  and screen == 'setts' then swich('autorun') printSetts()
  561.         elseif curX >= 3  and curX <= 14 and curY == 6  and screen == 'setts' then link(3,curY,'[Force Save]',colors.general) conf_S()
  562.         elseif (curY == 8 or curY == 13 or curY == 18)  and screen == 'parts' then
  563.             if     curX >= 20 and curX <= 22 then link(20,curY,'[+]',colors.general) local pid = (curY - 3)/5 config.partsPresets[partPreset][pid].radius = config.partsPresets[partPreset][pid].radius + 1 if config.partsPresets[partPreset][pid].radius >= 99 then config.partsPresets[partPreset][pid].radius = 99 end setText(27,curY,config.partsPresets[partPreset][pid].radius..' ',colors.gray)
  564.             elseif curX >= 23 and curX <= 25 then link(23,curY,'[-]',colors.general) local pid = (curY - 3)/5 config.partsPresets[partPreset][pid].radius = config.partsPresets[partPreset][pid].radius - 1 if config.partsPresets[partPreset][pid].radius <= 0 then config.partsPresets[partPreset][pid].radius = 0 end setText(27,curY,config.partsPresets[partPreset][pid].radius..' ',colors.gray)
  565.             elseif curX >= 30 and curX <= 32 then link(30,curY,'[+]',colors.general) local pid = (curY - 3)/5 config.partsPresets[partPreset][pid].height = config.partsPresets[partPreset][pid].height + 1 if config.partsPresets[partPreset][pid].height >= 99 then config.partsPresets[partPreset][pid].height = 99 end setText(37,curY,config.partsPresets[partPreset][pid].height..' ',colors.gray)
  566.             elseif curX >= 33 and curX <= 35 then link(33,curY,'[-]',colors.general) local pid = (curY - 3)/5 config.partsPresets[partPreset][pid].height = config.partsPresets[partPreset][pid].height - 1 if config.partsPresets[partPreset][pid].height <= -99 then config.partsPresets[partPreset][pid].height = -99 end setText(37,curY,config.partsPresets[partPreset][pid].height..' ',colors.gray)
  567.             elseif curX >= 41 and curX <= 45 then link(41,curY,'[куб]',colors.general) local pid = (curY - 3)/5 config.partsPresets[partPreset][pid].mode = true printSpawnList()
  568.             elseif curX >= 46 and curX <= 51 then link(46,curY,'[круг]',colors.general) local pid = (curY - 3)/5 config.partsPresets[partPreset][pid].mode = false printSpawnList()
  569.             elseif curX >= 52 and curX <= 54 then link(52,curY,'[x]',colors.general) local pid = (curY - 3)/5 config.partsPresets[partPreset][pid].name = false printSpawnList()
  570.             end
  571.         else dragParts = false
  572.         end
  573.     elseif evName == 'scroll' then
  574.         if curX >= 2 and curX <= 18 and curY >= 4 and curY <= 19 and screen == 'parts' then scrollMenu(2,4,16,16,scrollDir,partMass,colors.gray)
  575.         end
  576.     elseif evName == 'drop' then
  577.         if     curX >= 19 and curX <= 55 and curY >= 5 and curY <= 9 and dragParts and screen == 'parts' then config.partsPresets[partPreset][1].name = partMass[selectedPartID] printSpawnList()
  578.         elseif curX >= 19 and curX <= 55 and curY >= 10 and curY <= 14 and dragParts and screen == 'parts' then config.partsPresets[partPreset][2].name = partMass[selectedPartID] printSpawnList()
  579.         elseif curX >= 19 and curX <= 55 and curY >= 15 and curY <= 19 and dragParts and screen == 'parts' then config.partsPresets[partPreset][3].name = partMass[selectedPartID] printSpawnList()
  580.         end
  581.     end
  582. end
  583.  
  584. function run()
  585.     if fs.exists(configPath) then
  586.         conf_R()
  587.     else
  588.         conf_S()
  589.     end
  590.     checkPlayersTimer = startTimer(5,checkPlayer,math.huge)
  591.     press()
  592.     drawGui()
  593.     while work do
  594.         sleep(globalSleep)
  595.     end
  596.     exit()
  597. end
  598.  
  599. function start()
  600.     if g.getDepth() == 1 then
  601.         print('Ошибка! Монитор и видеокарта 1 тира не поддерживаются!')
  602.     else
  603.         if av('chat') then
  604.             chat = c.chat
  605.             listen('chat_message',chatLogging)
  606.             chatAccess = true
  607.         elseif av('chat_box') then
  608.             chat = c.chat_box
  609.             listen('chat_message',chatLogging)
  610.             chatAccess = true
  611.         else
  612.             chatAccess = false
  613.         end
  614.         if av('radar') then
  615.             r = c.radar
  616.             radarAccess = true
  617.         else
  618.             radarAccess = false
  619.         end
  620.         if av('particle') then
  621.             p = c.particle
  622.             particleAccess = true
  623.         else
  624.             particleAccess = false
  625.         end
  626.         run()
  627.     end
  628. end
  629.  
  630. function exit()
  631.     press('lock')
  632.     comp.beep(1500)
  633.     conf_S()
  634.     clear()
  635.     stopTimer(spawnTimer)
  636.     stopTimer(scanTimer)
  637.     stopTimer(checkPlayersTimer)
  638.     ignore('chat_message',chatLogging)
  639.     color(colors.white)
  640.     resol(wOld,hOld)
  641.     sleep(globalSleep)
  642. end
  643.  
  644. function ev.shouldInterrupt()
  645.     return false
  646. end
  647.  
  648. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement