local player = require("player") local STATES = { NONE = "none", BITE = "bite_detected", MINIGAME = "minigame", END = "end" } local state = STATES.NONE -- Внутренние переменные для логики состояний local lastState = nil -- Хранит последнее состояние (-1, 0, 1, или nil) local sneakStateOnEnter = false -- Состояние шифта в момент входа в центр (0) local success = 0 local fails = 0 -- Функция обрезки строки (с 14-го символа, убираем 18 с конца) local function trimActionBar(str) if not str then return "" end local bytes = {} for i = 1, math.min(#str, 14) do bytes[i] = string.byte(str, i) end --print("[DEBUG] Pattern not found. Bytes: \\" .. table.concat(bytes, "\\")) local s = string.sub(str, 13) --s = s:sub(1, -17) return s end -- Функция определения положения поплавка (копируем твою логику, но возвращаем nil для неизвестности) local function getProgress(str) -- 0 = Центр (поплавок в середине) if string.find(str, "\238\191\177\238\166\151\238\176\130", 1, true) or string.find(str, "\239\169\131\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\170\134\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\131\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\147\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\168\137\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\238\191\180\238\166\151\238\178\149", 1, true) or string.find(str, "\239\170\137\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\147\238\166\151\194\167\54\239\170\160", 1, true) then return 0 --end -- 1 = Конец (правый край) elseif string.find(str, "\239\170\144\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\170\144\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\170\144\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\169\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\169\152\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\169\130\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\169\148\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\169\162\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\170\153\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\160\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\169\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\144\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\170\149\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\152\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\130\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\153\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\170\170\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\170\146\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\170\136\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\161\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\144\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\170\147\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\170\147\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\150\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\167\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\170\152\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\170\131\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\168\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\166\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\170\129\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\137\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\180\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\167\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\170\135\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\129\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\132\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\150\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\132\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\177\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\176\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\130\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\132\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\170\128\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\165\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\170\148\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\170\152\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\170\153\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\168\144\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\168\169\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\168\180\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\169\137\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\170\136\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\170\146\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\170\170\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\168\134\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\170\147\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\170\131\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\170\129\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\169\167\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\169\166\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\168\168\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\168\167\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\168\165\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\170\148\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\170\135\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\170\128\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\169\150\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\169\132\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\169\129\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\168\177\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\168\176\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\168\137\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\170\132\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\182\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\178\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\177\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\165\238\166\151\194\167\54\239\170\160", 1, true) then return 1 -- -1 = Начало (левый край) -- 👇 Вставь сюда байты левого края, как только найдёшь их в логах elseif string.find(str, "\239\168\152\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\146\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\164\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\182\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\128\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\145\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\146\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\168\182\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\169\146\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\169\164\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\168\128\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\169\180\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\146\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\160\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\164\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\183\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\128\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\176\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\170\133\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\136\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\184\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\168\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\134\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\178\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\148\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\145\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\135\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\170\130\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\161\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\169\181\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\170\145\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\162\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\129\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\162\238\166\151\194\167\54\239\170\160", 1, true) or string.find(str, "\239\168\164\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\168\133\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\168\183\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\169\163\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\169\183\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\168\149\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\168\164\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\168\181\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\169\176\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\169\185\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\168\131\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\168\151\238\166\151\194\167\101\239\170\160", 1, true) or string.find(str, "\239\168\166\238\166\151\194\167\101\239\170\160", 1, true) then return -1 end -- Если ничего не найдено -> возвращаем nil (неопределенность) return nil end local function printStats() player.addMessage("[STATS] Success: " .. success .. " | Fails: " .. fails) end registerTitleEvent(function(text, isSubtitle) if not isSubtitle then local clean = text:gsub("§.", "") if clean == "BITE!" then state = STATES.BITE lastState = nil sneakStateOnEnter = false print("[MINIGAME] ▶ BITE! Логика -1/0/1 активна.!!!") elseif clean:find("FAIL!") then fails = fails + 1 state = STATES.END printStats() end end end) registerClientTick(function() -- Старт if state == STATES.BITE then player.input.rightClick() state = STATES.MINIGAME return end -- Основная логика управления if state == STATES.MINIGAME then local actionBar = player.getActionBar() if actionBar then local trimmed = trimActionBar(actionBar) local currentState = getProgress(trimmed) -- Если функция вернула false (из твоего старого кода), меняем на nil if currentState == false then currentState = nil end local targetSneak = nil -- nil означает "не менять состояние принудительно" -- 🟦 ЛЕВЫЙ КРАЙ (-1): Жмем шифт, пока не дойдем до центра (0) или конца (1) if currentState == -1 then targetSneak = true print("[Detection] Start") -- 🟥 ПРАВЫЙ КРАЙ (1): Отпускаем шифт, пока не дойдем до центра (0) или начала (-1) elseif currentState == 1 then targetSneak = false print("[Detection] End") -- 🟩 ЦЕНТР (0): Запоминаем состояние и стабилизируемся elseif currentState == 0 then -- Если мы только что вошли в центр, запоминаем текущее состояние шифта if lastState ~= 0 then sneakStateOnEnter = player.input.isPressedSneak() end print("[Detection] Center") -- В центре не меняем состояние (targetSneak остается nil) -- ⬛ НЕИЗВЕСТНО (nil): Корректируем движение elseif currentState == nil then if lastState == 0 then -- ВЫШЛИ ИЗ ЦЕНТРА: Корректируем в нужном направлении (инверсия состояния при входе) targetSneak = not sneakStateOnEnter elseif lastState == -1 then -- ИДЕМ ОТ ЛЕВОГО КРАЯ: Продолжаем жать шифт, чтобы дойти до центра targetSneak = true elseif lastState == 1 then -- ИДЕМ ОТ ПРАВОГО КРАЯ: Продолжаем держать шифт отпущенным targetSneak = false end -- Если lastState тоже nil (застряли в неизвестности), ничего не трогаем end -- Применяем состояние, если оно определено и отличается от текущего if targetSneak ~= nil then if player.input.isPressedSneak() ~= targetSneak then player.input.setPressedSneak(targetSneak) local action = targetSneak and "🔵 PRESS" or "🔴 RELEASE" print("[CTRL] Auto-adjust → " .. action) end end -- Вывод отладки, если состояние не распознано (nil) if currentState == nil and trimmed and #trimmed > 0 then -- Чтобы не спамить в чат каждый тик, выводим в консоль (print) -- Если нужно в чат, замени print на player.addMessage local bytes = {} for i = 1, math.min(#trimmed, 12) do bytes[i] = string.byte(trimmed, i) end print("[DEBUG] Pattern not found. Bytes: \\" .. table.concat(bytes, "\\")) end lastState = currentState end end -- 3️⃣ Сброс if state == STATES.END then player.input.setPressedSneak(false) player.input.rightClick() state = STATES.NONE lastState = nil end end) registerMessageEvent(function(text, overlay, json) if overlay and state == STATES.MINIGAME then local clean = text:gsub("§.", "") if clean:find("xp") then state = STATES.END success = success + 1 print("[MINIGAME] 🏁 Успешно завершено.") printStats() end end end)