Gintarus

ls чистый

Jul 1st, 2026 (edited)
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.39 KB | None | 0 0
  1. local component = require("component")
  2. local event = require("event")
  3. local computer = require("computer")
  4. local unicode = require("unicode")
  5.  
  6. local gpu = component.gpu
  7.  
  8. local function getComponent(...)
  9. for _, name in ipairs({...}) do
  10. local address = component.list(name)()
  11. if address then
  12. return component.proxy(address)
  13. end
  14. end
  15. return nil
  16. end
  17.  
  18. local chat = getComponent("chat_box")
  19. local opb = getComponent("openperipheral_bridge", "terminal_glasses_bridge", "terminal")
  20. local sensor = getComponent("sensor", "radar")
  21. local motionSensor = getComponent("motion_sensor")
  22.  
  23. if chat and chat.setName then
  24. pcall(chat.setName, "§3[PRISMA CHAT]§r")
  25. end
  26.  
  27. local w, h = gpu.getResolution()
  28. local minW, minH = 80, 24
  29. if w < minW or h < minH then
  30. pcall(gpu.setResolution, math.max(w, minW), math.max(h, minH))
  31. w, h = gpu.getResolution()
  32. end
  33.  
  34. local C = {
  35. bg = 0x071018,
  36. panel = 0x0D1C28,
  37. panel2 = 0x102638,
  38. line = 0x1D5A73,
  39. cyan = 0x00D7FF,
  40. blue = 0x3A8DFF,
  41. white = 0xE9FBFF,
  42. dim = 0x7092A4,
  43. green = 0x39FFB6,
  44. yellow = 0xFFD166,
  45. red = 0xFF4E6A,
  46. btn = 0x163142,
  47. btnOn = 0x064B40,
  48. btnWarn = 0x5A1E2B
  49. }
  50.  
  51. local mcColors = {
  52. ["0"] = 0x000000, ["1"] = 0x0000AA, ["2"] = 0x00AA00, ["3"] = 0x00AAAA,
  53. ["4"] = 0xAA0000, ["5"] = 0xAA00AA, ["6"] = 0xFFAA00, ["7"] = 0xAAAAAA,
  54. ["8"] = 0x555555, ["9"] = 0x5555FF, ["a"] = 0x55FF55, ["b"] = 0x55FFFF,
  55. ["c"] = 0xFF5555, ["d"] = 0xFF55FF, ["e"] = 0xFFFF55, ["f"] = 0xFFFFFF,
  56. ["r"] = C.white
  57. }
  58.  
  59. local cfg = {
  60. scanInterval = 2,
  61. motionTimeout = 8,
  62. arEnabled = true,
  63. arChatEnabled = true,
  64. arRadarEnabled = true,
  65. arX = 2,
  66. arY = 2,
  67. arW = 230,
  68. arChatWidth = 38,
  69. playerConfig = {
  70. ignore = {"GintaRus"},
  71. prefixes = {
  72. ["111"] = "[Чёрт] ",
  73. ["Noney"] = "[Girl] "
  74. }
  75. }
  76. }
  77.  
  78. local buttons = {}
  79. local chatLog = {}
  80. local arChatLog = {}
  81. local nearbyPlayers = {}
  82. local motionTargets = {}
  83. local showIgnoreMenu = false
  84. local needFullRedraw = true
  85. local chatUpdated = true
  86. local arError = nil
  87. local statusMessage = "Готово к работе"
  88. local lastScan = 0
  89.  
  90. local leftW = 30
  91. local bottomH = 5
  92. local chatX = leftW + 2
  93. local chatW = w - leftW - 1
  94. local chatH = h - bottomH - 4
  95.  
  96. local function clamp(v, a, b)
  97. if v < a then return a end
  98. if v > b then return b end
  99. return v
  100. end
  101.  
  102. local function text(x, y, value, fg, bg)
  103. gpu.setForeground(fg or C.white)
  104. gpu.setBackground(bg or C.bg)
  105. gpu.set(x, y, value)
  106. end
  107.  
  108. local function clearArea(x, y, bw, bh, bg)
  109. gpu.setBackground(bg or C.bg)
  110. gpu.fill(x, y, bw, bh, " ")
  111. end
  112.  
  113. local function frame(x, y, bw, bh, title)
  114. clearArea(x, y, bw, bh, C.panel)
  115. gpu.setForeground(C.line)
  116. gpu.setBackground(C.panel)
  117. gpu.set(x, y, "+" .. string.rep("-", bw - 2) .. "+")
  118. for i = 1, bh - 2 do
  119. gpu.set(x, y + i, "|")
  120. gpu.set(x + bw - 1, y + i, "|")
  121. end
  122. gpu.set(x, y + bh - 1, "+" .. string.rep("-", bw - 2) .. "+")
  123. if title then
  124. local label = " " .. title .. " "
  125. text(x + 2, y, label, C.cyan, C.panel)
  126. end
  127. end
  128.  
  129. local function drawButton(id, x, y, bw, label, bg, fg)
  130. buttons[id] = {x = x, y = y, w = bw, h = 1}
  131. clearArea(x, y, bw, 1, bg or C.btn)
  132. local lx = x + math.max(0, math.floor((bw - unicode.wlen(label)) / 2))
  133. text(lx, y, label, fg or C.white, bg or C.btn)
  134. end
  135.  
  136. local function buttonHit(id, x, y)
  137. local b = buttons[id]
  138. return b and x >= b.x and x < b.x + b.w and y >= b.y and y < b.y + b.h
  139. end
  140.  
  141. local function wrapText(value, maxW)
  142. local lines = {}
  143. local current = ""
  144. value = tostring(value or "")
  145. if maxW < 4 then maxW = 4 end
  146.  
  147. for word in value:gmatch("%S+") do
  148. if current == "" then
  149. current = word
  150. elseif unicode.wlen(current) + unicode.wlen(word) + 1 <= maxW then
  151. current = current .. " " .. word
  152. else
  153. table.insert(lines, current)
  154. current = word
  155. end
  156.  
  157. while unicode.wlen(current) > maxW do
  158. table.insert(lines, unicode.sub(current, 1, maxW))
  159. current = unicode.sub(current, maxW + 1)
  160. end
  161. end
  162.  
  163. if current ~= "" then
  164. table.insert(lines, current)
  165. end
  166. if #lines == 0 then
  167. table.insert(lines, "")
  168. end
  169. return lines
  170. end
  171.  
  172. local function drawColoredText(x, y, line, defaultColor, bg)
  173. local cx = x
  174. local color = defaultColor or C.white
  175. local safe = tostring(line or ""):gsub("§", "&")
  176. local pos = 1
  177.  
  178. gpu.setBackground(bg or C.panel)
  179. while pos <= #safe do
  180. local mark = safe:find("&", pos, true)
  181. if not mark then
  182. gpu.setForeground(color)
  183. gpu.set(cx, y, safe:sub(pos))
  184. break
  185. end
  186.  
  187. if mark > pos then
  188. local chunk = safe:sub(pos, mark - 1)
  189. gpu.setForeground(color)
  190. gpu.set(cx, y, chunk)
  191. cx = cx + unicode.wlen(chunk)
  192. end
  193.  
  194. local code = safe:sub(mark + 1, mark + 1):lower()
  195. if mcColors[code] then
  196. color = mcColors[code]
  197. pos = mark + 2
  198. else
  199. gpu.setForeground(color)
  200. gpu.set(cx, y, "&")
  201. cx = cx + 1
  202. pos = mark + 1
  203. end
  204. end
  205. end
  206.  
  207. local isIgnored
  208.  
  209. local function decoratedName(name)
  210. local prefix = cfg.playerConfig.prefixes[name]
  211. if prefix then
  212. return prefix .. name
  213. end
  214. return name
  215. end
  216.  
  217. local function formatDistance(value)
  218. if not value then
  219. return ""
  220. end
  221. return string.format(" %.1fm", value)
  222. end
  223.  
  224. local function addNearbyPlayer(seen, name, distance)
  225. if not name or name == "" or isIgnored(name) then
  226. return
  227. end
  228.  
  229. local shown = decoratedName(name)
  230. local key = shown:lower()
  231. if seen[key] then
  232. return
  233. end
  234.  
  235. seen[key] = true
  236. table.insert(nearbyPlayers, shown .. formatDistance(distance))
  237. end
  238.  
  239. local function handleMotionSignal(a, b, c, d, e)
  240. local dx, dy, dz, name
  241.  
  242. if type(a) == "number" then
  243. dx, dy, dz, name = a, b, c, d
  244. elseif type(b) == "number" then
  245. dx, dy, dz, name = b, c, d, e
  246. else
  247. return
  248. end
  249.  
  250. if type(dx) ~= "number" or type(dy) ~= "number" or type(dz) ~= "number" then
  251. return
  252. end
  253.  
  254. name = tostring(name or "Движение")
  255. local distance = math.sqrt(dx * dx + dy * dy + dz * dz)
  256. motionTargets[name] = {
  257. distance = distance,
  258. time = computer.uptime()
  259. }
  260. statusMessage = "Движение: " .. name .. string.format(" %.1fm", distance)
  261. end
  262.  
  263. function isIgnored(name)
  264. for _, ignored in ipairs(cfg.playerConfig.ignore) do
  265. if tostring(name):lower() == tostring(ignored):lower() then
  266. return true
  267. end
  268. end
  269. return false
  270. end
  271.  
  272. local function addChatMessage(name, message)
  273. name = tostring(name or "Unknown")
  274. message = tostring(message or "")
  275. if message:sub(1, 1) == "!" then return end
  276.  
  277. local shownName = decoratedName(name)
  278. local prefix = "&8> &b" .. shownName .. "&8: &f"
  279. local firstWidth = math.max(10, chatW - 8 - unicode.wlen(shownName) - 4)
  280. local restWidth = math.max(10, chatW - 8)
  281. local wrapped = wrapText(message, firstWidth)
  282.  
  283. for i, line in ipairs(wrapped) do
  284. if i == 1 then
  285. table.insert(chatLog, prefix .. line)
  286. else
  287. for _, restLine in ipairs(wrapText(line, restWidth)) do
  288. table.insert(chatLog, "&f " .. restLine)
  289. end
  290. end
  291. end
  292.  
  293. while #chatLog > chatH - 2 do
  294. table.remove(chatLog, 1)
  295. end
  296.  
  297. table.insert(arChatLog, {type = "name", text = shownName})
  298. for _, line in ipairs(wrapText(message, cfg.arChatWidth)) do
  299. table.insert(arChatLog, {type = "msg", text = line})
  300. end
  301. while #arChatLog > 12 do
  302. table.remove(arChatLog, 1)
  303. end
  304.  
  305. statusMessage = "Новое сообщение от " .. name
  306. chatUpdated = true
  307. end
  308.  
  309. local function extractPlayerName(key, value)
  310. if type(value) == "string" then return value end
  311. if type(value) == "table" then
  312. return value.name or value.username or value.player or value[1]
  313. end
  314. if type(key) == "string" then return key end
  315. return nil
  316. end
  317.  
  318. local function sortPlayers()
  319. table.sort(nearbyPlayers, function(a, b)
  320. return a:lower() < b:lower()
  321. end)
  322. end
  323.  
  324. local function scanEnvironment()
  325. nearbyPlayers = {}
  326. local seen = {}
  327.  
  328. if sensor then
  329. local ok, result = pcall(function()
  330. if sensor.getPlayers then
  331. return sensor.getPlayers()
  332. elseif sensor.getPlayerNames then
  333. return sensor.getPlayerNames()
  334. elseif sensor.players then
  335. return sensor.players()
  336. end
  337. end)
  338.  
  339. if ok and type(result) == "table" then
  340. for key, value in pairs(result) do
  341. addNearbyPlayer(seen, extractPlayerName(key, value))
  342. end
  343. else
  344. statusMessage = "Сенсор списка не отвечает"
  345. end
  346. end
  347.  
  348. local now = computer.uptime()
  349. for name, data in pairs(motionTargets) do
  350. if now - data.time <= cfg.motionTimeout then
  351. addNearbyPlayer(seen, name, data.distance)
  352. else
  353. motionTargets[name] = nil
  354. end
  355. end
  356.  
  357. sortPlayers()
  358. if sensor then
  359. statusMessage = "Сканирование: " .. tostring(#nearbyPlayers) .. " игрок(ов)"
  360. elseif motionSensor then
  361. statusMessage = "Motion sensor: последние движения, радиус 8"
  362. else
  363. statusMessage = "Сенсор не найден"
  364. end
  365. end
  366.  
  367. local function updateAR()
  368. if not opb or not cfg.arEnabled then return end
  369.  
  370. local ok, err = pcall(function()
  371. opb.clear()
  372.  
  373. local bx, by, bw = cfg.arX, cfg.arY, cfg.arW
  374. local radarH = cfg.arRadarEnabled and math.max(32, 18 + (#nearbyPlayers * 8)) or 0
  375. local chatLines = cfg.arChatEnabled and #arChatLog or 0
  376. local chatHpx = cfg.arChatEnabled and math.max(24, 12 + chatLines * 8) or 0
  377. local totalH = math.max(36, radarH + chatHpx + 12)
  378.  
  379. opb.addBox(bx, by, bw, totalH, 0x06111A, 0.45)
  380. opb.addBox(bx, by, bw, 1, 0x00D7FF, 0.65)
  381. opb.addText(bx + 6, by + 4, "PRISMA CHAT", 0x00D7FF).setScale(0.8)
  382.  
  383. local y = by + 16
  384. if cfg.arRadarEnabled then
  385. opb.addText(bx + 6, y, "ИГРОКИ РЯДОМ: " .. tostring(#nearbyPlayers), 0x39FFB6).setScale(0.7)
  386. y = y + 9
  387. if #nearbyPlayers == 0 then
  388. opb.addText(bx + 10, y, "никого нет", 0x7092A4).setScale(0.7)
  389. y = y + 9
  390. else
  391. for i, name in ipairs(nearbyPlayers) do
  392. if i <= 10 then
  393. opb.addText(bx + 10, y, "- " .. name, 0xE9FBFF).setScale(0.7)
  394. y = y + 8
  395. end
  396. end
  397. end
  398. y = y + 5
  399. end
  400.  
  401. if cfg.arChatEnabled then
  402. opb.addText(bx + 6, y, "ЧАТ", 0x00D7FF).setScale(0.7)
  403. y = y + 9
  404. for _, item in ipairs(arChatLog) do
  405. if item.type == "name" then
  406. opb.addText(bx + 10, y, item.text .. ":", 0x00D7FF).setScale(0.7)
  407. else
  408. opb.addText(bx + 14, y, item.text, 0xE9FBFF).setScale(0.7)
  409. end
  410. y = y + 8
  411. end
  412. end
  413.  
  414. opb.sync()
  415. end)
  416.  
  417. if ok then
  418. arError = nil
  419. else
  420. arError = tostring(err)
  421. end
  422. end
  423.  
  424. local function drawHeader()
  425. clearArea(1, 1, w, 2, C.bg)
  426. text(2, 1, "PRISMA CHAT // локальная связь и сенсор", C.cyan, C.bg)
  427. local clock = string.format("UP %ds", math.floor(computer.uptime()))
  428. text(w - unicode.wlen(clock) - 1, 1, clock, C.dim, C.bg)
  429. gpu.setBackground(C.bg)
  430. gpu.setForeground(C.line)
  431. gpu.fill(1, 2, w, 1, "-")
  432. end
  433.  
  434. local function drawPlayers()
  435. frame(1, 3, leftW, h - bottomH - 2, "Игроки рядом")
  436. local status = "сенсор: не найден"
  437. local statusColor = C.red
  438. if sensor then
  439. status = "сенсор: список игроков"
  440. statusColor = C.green
  441. elseif motionSensor then
  442. status = "сенсор: движение"
  443. statusColor = C.yellow
  444. end
  445. text(3, 5, status, statusColor, C.panel)
  446. text(3, 6, "найдено: " .. tostring(#nearbyPlayers), C.white, C.panel)
  447. if motionSensor then
  448. text(3, 7, "радиус OC: 8 блоков", C.dim, C.panel)
  449. end
  450.  
  451. local listY = 9
  452. local maxRows = h - bottomH - listY - 1
  453. clearArea(3, listY, leftW - 4, maxRows, C.panel)
  454.  
  455. if #nearbyPlayers == 0 then
  456. text(4, listY, "Пусто", C.dim, C.panel)
  457. else
  458. for i = 1, math.min(#nearbyPlayers, maxRows) do
  459. local name = unicode.sub(nearbyPlayers[i], 1, leftW - 8)
  460. text(4, listY + i - 1, string.format("%02d ", i), C.dim, C.panel)
  461. text(7, listY + i - 1, name, C.white, C.panel)
  462. end
  463. end
  464. end
  465.  
  466. local function drawChat()
  467. frame(chatX, 3, chatW, chatH + 2, "Чат")
  468. clearArea(chatX + 2, 4, chatW - 4, chatH, C.panel)
  469.  
  470. if #chatLog == 0 then
  471. text(chatX + 3, 5, "Сообщений пока нет", C.dim, C.panel)
  472. return
  473. end
  474.  
  475. local start = math.max(1, #chatLog - chatH + 1)
  476. local y = 4
  477. for i = start, #chatLog do
  478. drawColoredText(chatX + 2, y, unicode.sub(chatLog[i], 1, chatW - 4), C.white, C.panel)
  479. y = y + 1
  480. end
  481. end
  482.  
  483. local function drawFooter()
  484. local y = h - bottomH + 1
  485. frame(1, y, w, bottomH, "Управление")
  486.  
  487. drawButton("toggle_ar", 3, y + 2, 10, cfg.arEnabled and "AR вкл" or "AR выкл", cfg.arEnabled and C.btnOn or C.btn, cfg.arEnabled and C.green or C.dim)
  488. drawButton("toggle_ar_chat", 15, y + 2, 12, cfg.arChatEnabled and "чат AR" or "без чата", cfg.arChatEnabled and C.btnOn or C.btn, cfg.arChatEnabled and C.green or C.dim)
  489. drawButton("toggle_ar_radar", 29, y + 2, 14, cfg.arRadarEnabled and "сенсор AR" or "без сенс.", cfg.arRadarEnabled and C.btnOn or C.btn, cfg.arRadarEnabled and C.green or C.dim)
  490. drawButton("ignore", 45, y + 2, 12, "игнор", C.btn, C.white)
  491. drawButton("prefix", 59, y + 2, 12, "префикс", C.btn, C.cyan)
  492.  
  493. local info = statusMessage
  494. if arError then
  495. info = "AR ошибка: " .. arError
  496. elseif not opb then
  497. info = info .. " | AR-мост не найден"
  498. end
  499. text(3, y + 3, unicode.sub(info, 1, w - 5), arError and C.red or C.dim, C.panel)
  500. end
  501.  
  502. local function redraw()
  503. buttons = {}
  504. clearArea(1, 1, w, h, C.bg)
  505. drawHeader()
  506. drawPlayers()
  507. drawChat()
  508. drawFooter()
  509. needFullRedraw = false
  510. chatUpdated = false
  511. end
  512.  
  513. local function redrawDynamic()
  514. drawHeader()
  515. drawPlayers()
  516. if chatUpdated then
  517. drawChat()
  518. chatUpdated = false
  519. end
  520. drawFooter()
  521. end
  522.  
  523. local function readInput(title, prompt)
  524. while event.pull(0) do end
  525.  
  526. local mw, mh = 54, 8
  527. local mx = math.floor((w - mw) / 2)
  528. local my = math.floor((h - mh) / 2)
  529. local value = ""
  530. local inputX = mx + unicode.wlen(prompt) + 5
  531. local inputW = mw - unicode.wlen(prompt) - 8
  532. local redrawInput = true
  533.  
  534. while true do
  535. if redrawInput then
  536. clearArea(mx, my, mw, mh, C.panel2)
  537. frame(mx, my, mw, mh, title)
  538. text(mx + 3, my + 3, prompt .. ":", C.white, C.panel)
  539. clearArea(inputX, my + 3, inputW, 1, C.bg)
  540. text(inputX, my + 3, unicode.sub(value .. "_", -inputW + 1), C.cyan, C.bg)
  541. drawButton("input_ok", mx + 7, my + 5, 16, "OK", C.btnOn, C.green)
  542. drawButton("input_cancel", mx + 31, my + 5, 16, "Отмена", C.btnWarn, C.red)
  543. redrawInput = false
  544. end
  545.  
  546. local ev, _, a1, a2 = event.pull()
  547. if ev == "key_down" then
  548. if a2 == 28 then
  549. break
  550. elseif a2 == 14 then
  551. if unicode.wlen(value) > 0 then
  552. value = unicode.sub(value, 1, -2)
  553. redrawInput = true
  554. end
  555. elseif a2 == 1 then
  556. value = nil
  557. break
  558. elseif a1 and a1 >= 32 and unicode.wlen(value) < 32 then
  559. local ok, ch = pcall(unicode.char, a1)
  560. if ok and ch then
  561. value = value .. ch
  562. redrawInput = true
  563. end
  564. end
  565. elseif ev == "touch" then
  566. local tx, ty = a1, a2
  567. if buttonHit("input_ok", tx, ty) then
  568. break
  569. elseif buttonHit("input_cancel", tx, ty) then
  570. value = nil
  571. break
  572. end
  573. end
  574. end
  575.  
  576. buttons["input_ok"] = nil
  577. buttons["input_cancel"] = nil
  578. needFullRedraw = true
  579. return value
  580. end
  581.  
  582. local function drawIgnoreMenu()
  583. local mw, mh = 48, 14
  584. local mx = math.floor((w - mw) / 2)
  585. local my = math.floor((h - mh) / 2)
  586. clearArea(mx, my, mw, mh, C.panel2)
  587. frame(mx, my, mw, mh, "Игнор-лист")
  588.  
  589. if #cfg.playerConfig.ignore == 0 then
  590. text(mx + 4, my + 3, "Список пуст", C.dim, C.panel)
  591. else
  592. for i = 1, math.min(6, #cfg.playerConfig.ignore) do
  593. local name = unicode.sub(cfg.playerConfig.ignore[i], 1, 22)
  594. text(mx + 4, my + 2 + i, tostring(i) .. ". " .. name, C.white, C.panel)
  595. drawButton("unignore_" .. i, mx + 32, my + 2 + i, 12, "убрать", C.btnWarn, C.red)
  596. end
  597. end
  598.  
  599. drawButton("ignore_add", mx + 4, my + mh - 2, 14, "добавить", C.btnOn, C.green)
  600. drawButton("ignore_close", mx + mw - 16, my + mh - 2, 12, "закрыть", C.btn, C.white)
  601. end
  602.  
  603. local function openIgnoreMenu()
  604. showIgnoreMenu = true
  605. drawIgnoreMenu()
  606. end
  607.  
  608. local function handleIgnoreTouch(x, y)
  609. if buttonHit("ignore_close", x, y) then
  610. showIgnoreMenu = false
  611. needFullRedraw = true
  612. return
  613. end
  614.  
  615. if buttonHit("ignore_add", x, y) then
  616. local name = readInput("Добавить в игнор", "Ник")
  617. if name and name ~= "" and not isIgnored(name) then
  618. table.insert(cfg.playerConfig.ignore, name)
  619. scanEnvironment()
  620. updateAR()
  621. end
  622. showIgnoreMenu = true
  623. drawIgnoreMenu()
  624. return
  625. end
  626.  
  627. for i = 1, 6 do
  628. if buttonHit("unignore_" .. i, x, y) then
  629. table.remove(cfg.playerConfig.ignore, i)
  630. scanEnvironment()
  631. updateAR()
  632. drawIgnoreMenu()
  633. return
  634. end
  635. end
  636. end
  637.  
  638. local function handleTouch(x, y)
  639. if showIgnoreMenu then
  640. handleIgnoreTouch(x, y)
  641. return
  642. end
  643.  
  644. if buttonHit("toggle_ar", x, y) then
  645. cfg.arEnabled = not cfg.arEnabled
  646. if opb and not cfg.arEnabled then
  647. pcall(opb.clear)
  648. pcall(opb.sync)
  649. end
  650. needFullRedraw = true
  651. elseif buttonHit("toggle_ar_chat", x, y) then
  652. cfg.arChatEnabled = not cfg.arChatEnabled
  653. updateAR()
  654. needFullRedraw = true
  655. elseif buttonHit("toggle_ar_radar", x, y) then
  656. cfg.arRadarEnabled = not cfg.arRadarEnabled
  657. updateAR()
  658. needFullRedraw = true
  659. elseif buttonHit("ignore", x, y) then
  660. openIgnoreMenu()
  661. elseif buttonHit("prefix", x, y) then
  662. local name = readInput("Префикс игрока", "Ник")
  663. if name and name ~= "" then
  664. local prefix = readInput("Префикс игрока", "Префикс")
  665. if prefix then
  666. if prefix == "" then
  667. cfg.playerConfig.prefixes[name] = nil
  668. else
  669. cfg.playerConfig.prefixes[name] = prefix .. " "
  670. end
  671. scanEnvironment()
  672. updateAR()
  673. end
  674. end
  675. needFullRedraw = true
  676. end
  677. end
  678.  
  679. scanEnvironment()
  680. redraw()
  681. updateAR()
  682.  
  683. while true do
  684. local ev, a, b, c, d, e = event.pull(0.5)
  685.  
  686. if ev == "chat_message" then
  687. if c ~= nil then
  688. addChatMessage(b, c)
  689. else
  690. addChatMessage(a, b)
  691. end
  692. updateAR()
  693. elseif ev == "touch" then
  694. if type(b) == "number" then
  695. handleTouch(b, c)
  696. else
  697. handleTouch(a, b)
  698. end
  699. elseif ev == "motion" then
  700. handleMotionSignal(a, b, c, d, e)
  701. scanEnvironment()
  702. updateAR()
  703. needFullRedraw = true
  704. elseif ev == "interrupted" then
  705. clearArea(1, 1, w, h, 0x000000)
  706. if opb then
  707. pcall(opb.clear)
  708. pcall(opb.sync)
  709. end
  710. return
  711. end
  712.  
  713. local now = computer.uptime()
  714. if now - lastScan >= cfg.scanInterval then
  715. scanEnvironment()
  716. updateAR()
  717. lastScan = now
  718. end
  719.  
  720. if needFullRedraw then
  721. redraw()
  722. elseif not showIgnoreMenu then
  723. redrawDynamic()
  724. end
  725. end
  726.  
Advertisement
Add Comment
Please, Sign In to add comment