local myPlayer = nil local enemyBot = nil local isMirrorActive = true local mirrorGroup = display.newGroup() -- Глибокий пошук об'єктів local function findDeep(parent, name, minX, maxX) if not parent or not parent.numChildren then return nil end for i = 1, parent.numChildren do local obj = parent[i] if obj and obj.x then if tostring(obj.name) == name and obj.x >= minX and obj.x <= maxX then return obj end if obj.numChildren and obj.numChildren > 0 then local found = findDeep(obj, name, minX, maxX) if found then return found end end end end return nil end -- Основна логіка синхронізації local function syncAll() if not isMirrorActive then return end -- Пошук, якщо об'єкти ще не знайдені if not myPlayer or not myPlayer.x then myPlayer = findDeep(display.currentStage, "paddle", 0, 400) end if not enemyBot or not enemyBot.x then enemyBot = findDeep(display.currentStage, "paddle", 500, 1200) end if myPlayer and enemyBot then -- Вираховуємо дзеркальну позицію X -- Якщо ти на X=100, бот має бути на X=860 (відстань від краю) local screenW = display.contentWidth local targetX = screenW - myPlayer.x local targetY = myPlayer.y -- Жорстка синхронізація (перебиваємо внутрішній ШІ бота) pcall(function() enemyBot.x = targetX enemyBot.y = targetY -- Зупиняємо власну швидкість бота, щоб його AI не "смикав" об'єкт if enemyBot.setLinearVelocity then enemyBot:setLinearVelocity(0, 0) end end) end end -- Кнопка видалення скрипту local function createUI() if mirrorGroup.numChildren > 0 then return end local btn = display.newRoundedRect(mirrorGroup, display.contentWidth - 100, 50, 140, 40, 10) btn:setFillColor(0.8, 0.2, 0.2, 0.8) local txt = display.newText(mirrorGroup, "STOP & DELETE", btn.x, btn.y, native.systemFontBold, 14) btn:addEventListener("tap", function() isMirrorActive = false Runtime:removeEventListener("enterFrame", syncAll) mirrorGroup:removeSelf() print("Mirror Script Deleted!") return true end) end -- Запуск createUI() Runtime:removeEventListener("enterFrame", syncAll) Runtime:addEventListener("enterFrame", syncAll) print("Mirror Bot v3.0: Full X/Y Sync Active")