-- ══════════════════════════════════════════════════
-- NYX JOYSTICK v9 + BALL PREDICT · Volleyball Legends
-- Стик 1 + Стик 2 (круг с направлениями WASD) + кнопки направлений
-- Roblox (мобильный, Delta). Повторный запуск перезагружает скрипт.
-- ══════════════════════════════════════════════════
local CONFIG_FILE = "NyxJoystick.json"
local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local HttpService = game:GetService("HttpService")
local WS = game:GetService("Workspace")
local lp = Players.LocalPlayer
if getgenv and getgenv().__NyxJoystickCleanup then
pcall(getgenv().__NyxJoystickCleanup)
end
-- подстраховка: чистим остатки прошлого запуска, даже если cleanup не сработал
pcall(function() RunService:UnbindFromRenderStep("NyxJoystick") end)
do
local roots = { game:GetService("CoreGui"), lp:FindFirstChildOfClass("PlayerGui") }
if gethui then table.insert(roots, gethui()) end
local cam = WS.CurrentCamera
if cam then table.insert(roots, cam) end
for _, root in ipairs(roots) do
for _, ch in ipairs(root:GetChildren()) do
if ch.Name == "NyxJoystick" or ch.Name == "BPPredictLine" or ch.Name == "BPPredictMarker" then
pcall(function() ch:Destroy() end)
end
end
end
end
---------------------------------------------------------------- данные
local KEYS = {
{ id = "WA", text = "W+A", dir = Vector2.new(-1, -1), c = 0, r = 0 },
{ id = "W", text = "W", dir = Vector2.new(0, -1), c = 1, r = 0 },
{ id = "WD", text = "W+D", dir = Vector2.new(1, -1), c = 2, r = 0 },
{ id = "A", text = "A", dir = Vector2.new(-1, 0), c = 0, r = 1 },
{ id = "D", text = "D", dir = Vector2.new(1, 0), c = 2, r = 1 },
{ id = "SA", text = "S+A", dir = Vector2.new(-1, 1), c = 0, r = 2 },
{ id = "S", text = "S", dir = Vector2.new(0, 1), c = 1, r = 2 },
{ id = "SD", text = "S+D", dir = Vector2.new(1, 1), c = 2, r = 2 },
}
local COLS = { 0.70, 0.80, 0.90 }
local ROWS = { 0.40, 0.60, 0.80 }
local PRESS_COLORS = {
Color3.fromRGB(0, 170, 255),
Color3.fromRGB(0, 220, 120),
Color3.fromRGB(255, 70, 70),
Color3.fromRGB(255, 255, 255),
Color3.fromRGB(180, 90, 255),
Color3.fromRGB(255, 190, 0),
}
-- сектора стика 2: угол по часовой стрелке от "вперёд"
local SECT = {
{ text = "W", ang = 0, diag = false },
{ text = "W+D", ang = 45, diag = true },
{ text = "D", ang = 90, diag = false },
{ text = "S+D", ang = 135, diag = true },
{ text = "S", ang = 180, diag = false },
{ text = "S+A", ang = 225, diag = true },
{ text = "A", ang = 270, diag = false },
{ text = "W+A", ang = 315, diag = true },
}
local function dirOf(angDeg)
local r = math.rad(angDeg)
return Vector2.new(math.sin(r), -math.cos(r))
end
local function angleOf(dir)
return math.deg(math.atan2(dir.X, -dir.Y)) % 360
end
-- n = 8 или 4; prev = текущий сектор; hys = запас в градусах против дрожания на границе
local function sectorOf(dir, n, prev, hys)
local a = angleOf(dir)
local step = 360 / n
if prev and (n == 8 or not SECT[prev].diag) then
local diff = math.abs((a - SECT[prev].ang + 180) % 360 - 180)
if diff <= step / 2 + hys then return prev end
end
local idx = math.floor((a + step / 2) / step) % n
return idx * (8 / n) + 1
end
local function K(id, s) return "B_" .. id .. "_" .. s end
local DEFAULT = {
-- стик 1
On = 1,
Size = 170, X = 0.14, Y = 0.72,
Deadzone = 0.04, Opacity = 0.55,
Adaptive = 1, Follow = 1, TapDir = 0,
-- стик 2: поведение
S2_On = 0,
S2_Size = 200, S2_X = 0.38, S2_Y = 0.66,
S2_Deadzone = 0.1, S2_Adaptive = 0, S2_Follow = 0, S2_TapDir = 1,
S2_Snap = 1, S2_Dirs = 8, S2_Hys = 4,
-- стик 2: вид
S2_Opacity = 0.6, S2_Round = 0.5, S2_Stroke = 1, S2_StrokeW = 2,
S2_Letters = 1, S2_LetterSize = 0.24, S2_DiagScale = 0.6,
S2_LetterDist = 0.72, S2_LetterOp = 0.9, S2_Lines = 0,
S2_Knob = 0.42, S2_KnobOn = 1, S2_KnobSnap = 0,
S2_Color = 1,
-- кнопки
BtnSize = 60, BtnOpacity = 0.55, BtnRound = 0.2,
BtnLabels = 1, BtnStroke = 1, BtnLatch = 0, BtnColor = 1,
-- предикт
PredictOn = 1, RayLength = 80,
-- оптимизация (1 = пункт включён, то есть этот вид нагрузки убирается)
OptOn = 1, OptShadows = 1, OptAtmos = 1, OptPost = 1, OptReflect = 1,
OptWater = 1, OptQuality = 1, OptEffects = 1, OptDecals = 1, OptPurge = 0,
OptMeshTex = 0, OptMeshFid = 1, OptSounds = 0, OptFpsOn = 1, OptFps = 60,
OptGC = 1, OptMemLimit = 1400,
LineWidth = 0.2, MarkerSize = 1.5,
ColorR = 0, ColorG = 255, ColorB = 255,
-- интерфейс
GearX = 0.92, GearY = 0.2,
PanelX = 0.5, PanelY = 0.5,
}
for _, k in ipairs(KEYS) do
DEFAULT[K(k.id, "On")] = 1
DEFAULT[K(k.id, "X")] = COLS[k.c + 1]
DEFAULT[K(k.id, "Y")] = ROWS[k.r + 1]
DEFAULT[K(k.id, "Scale")] = 1
end
---------------------------------------------------------------- конфиг
local cfg = {}
for k, v in pairs(DEFAULT) do cfg[k] = v end
local function loadCfg()
if isfile and readfile and isfile(CONFIG_FILE) then
local ok, data = pcall(function()
return HttpService:JSONDecode(readfile(CONFIG_FILE))
end)
if ok and type(data) == "table" then
for k in pairs(DEFAULT) do
if type(data[k]) == "number" then cfg[k] = data[k] end
end
end
end
end
local function saveCfg()
if writefile then
pcall(writefile, CONFIG_FILE, HttpService:JSONEncode(cfg))
end
end
loadCfg()
---------------------------------------------------------------- GUI
local gui = Instance.new("ScreenGui")
gui.Name = "NyxJoystick"
gui.ResetOnSpawn = false
gui.IgnoreGuiInset = false
gui.DisplayOrder = 999
gui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
local okParent = pcall(function()
gui.Parent = (gethui and gethui()) or game:GetService("CoreGui")
end)
if not okParent or not gui.Parent then
gui.Parent = lp:WaitForChild("PlayerGui")
end
local DARK = Color3.fromRGB(20, 20, 20)
local BLUE = Color3.fromRGB(0, 170, 255)
local WHITE = Color3.new(1, 1, 1)
local GREY = Color3.fromRGB(55, 55, 55)
local ON = Color3.fromRGB(0, 120, 190)
local GREEN = Color3.fromRGB(0, 140, 90)
local YELLOW = Color3.fromRGB(255, 200, 0)
local KNOB = Color3.fromRGB(240, 240, 240)
local LETTER_IDLE = Color3.fromRGB(215, 215, 215)
local function round(parent, radius)
local c = Instance.new("UICorner", parent)
c.CornerRadius = radius or UDim.new(1, 0)
return c
end
local function stroke(parent, color, transparency, thickness)
local s = Instance.new("UIStroke", parent)
s.Color = color
s.Transparency = transparency
s.Thickness = thickness
return s
end
local function pressColor(idx)
return PRESS_COLORS[math.clamp(math.floor(idx + 0.5), 1, #PRESS_COLORS)]
end
local editMode = false
local selectMode = false
local selId = KEYS[2].id
local pressed = {}
local onSelect = function() end
local applyLayout, applyVisual
---------------------------------------------------------------- ввод: общие хелперы
local conns = {}
local function isPress(i)
return i.UserInputType == Enum.UserInputType.Touch
or i.UserInputType == Enum.UserInputType.MouseButton1
end
local function bindDrag(obj, onBegin, onMove, onEnd)
local cur
table.insert(conns, obj.InputBegan:Connect(function(i)
if isPress(i) and not cur then
if onBegin and onBegin(i) == false then return end
cur = i
onMove(i)
end
end))
table.insert(conns, UIS.InputChanged:Connect(function(i)
if cur and (i == cur or (cur.UserInputType == Enum.UserInputType.MouseButton1
and i.UserInputType == Enum.UserInputType.MouseMovement)) then
onMove(i)
end
end))
table.insert(conns, UIS.InputEnded:Connect(function(i)
if i == cur then
cur = nil
if onEnd then onEnd(i) end
end
end))
end
-- "Умный" тап для меню: срабатывает, только если палец почти не сдвинулся
-- и список под ним не прокрутился. Прокрутка меню ничего не нажимает.
local function onTap(obj, fn)
local scroller = obj:FindFirstAncestorOfClass("ScrollingFrame")
local tracking, startPos, startCanvas
table.insert(conns, obj.InputBegan:Connect(function(i)
if isPress(i) and not tracking then
tracking = i
startPos = Vector2.new(i.Position.X, i.Position.Y)
startCanvas = scroller and scroller.CanvasPosition or Vector2.zero
end
end))
table.insert(conns, UIS.InputEnded:Connect(function(i)
if i == tracking then
tracking = nil
local moved = (Vector2.new(i.Position.X, i.Position.Y) - startPos).Magnitude
local scrolled = scroller and (scroller.CanvasPosition - startCanvas).Magnitude or 0
if moved < 14 and scrolled < 3 then fn(i) end
end
end))
end
local function objCenter(o)
return o.AbsolutePosition + o.AbsoluteSize / 2
end
local function clampPos(kx, ky, size)
local v = gui.AbsoluteSize
if v.X <= 0 or v.Y <= 0 then return end
local r = size / 2
cfg[kx] = math.clamp(cfg[kx], r / v.X, 1 - r / v.X)
cfg[ky] = math.clamp(cfg[ky], r / v.Y, 1 - r / v.Y)
end
local function makeMover(obj, kx, ky, selectId)
local off = Vector2.zero
bindDrag(obj,
function(i)
if not editMode then return false end
if selectId then
selId = selectId
onSelect()
end
off = objCenter(obj) - Vector2.new(i.Position.X, i.Position.Y)
end,
function(i)
if not editMode then return end
local v = gui.AbsoluteSize
local p = Vector2.new(i.Position.X, i.Position.Y) + off
cfg[kx] = p.X / v.X
cfg[ky] = p.Y / v.Y
applyLayout()
end,
saveCfg)
end
---------------------------------------------------------------- фабрика стиков
-- p = "" для стика 1, "S2_" для стика 2 (круг с направлениями)
local function newStick(p, compass)
local S = { axis = Vector2.zero, sector = nil, origin = Vector2.zero }
local function g(n) return cfg[p .. n] end
local base = Instance.new("Frame")
base.Name = compass and "Stick2Base" or "Base"
base.AnchorPoint = Vector2.new(0.5, 0.5)
base.BackgroundColor3 = DARK
base.BorderSizePixel = 0
base.Active = true
base.Parent = gui
local corner = round(base)
local baseStroke = stroke(base, WHITE, 0.5, 2)
local lines, labels = {}, {}
if compass then
-- разделители секторов (по желанию)
for k = 1, 4 do
local l = Instance.new("Frame")
l.AnchorPoint = Vector2.new(0.5, 0.5)
l.Position = UDim2.fromScale(0.5, 0.5)
l.BackgroundColor3 = WHITE
l.BorderSizePixel = 0
l.ZIndex = 2
l.Parent = base
lines[k] = l
end
-- буквы: только текст, без фона
for i, sec in ipairs(SECT) do
local t = Instance.new("TextLabel")
t.AnchorPoint = Vector2.new(0.5, 0.5)
t.BackgroundTransparency = 1
t.BorderSizePixel = 0
t.Font = Enum.Font.GothamBold
t.TextScaled = true
t.TextColor3 = LETTER_IDLE
t.Text = sec.text
t.ZIndex = 5
t.Parent = base
labels[i] = t
end
end
-- ручка (точка в центре, как в стике 1)
local knob = Instance.new("Frame")
knob.Name = "Knob"
knob.AnchorPoint = Vector2.new(0.5, 0.5)
knob.Position = UDim2.fromScale(0.5, 0.5)
knob.BackgroundColor3 = KNOB
knob.BorderSizePixel = 0
knob.ZIndex = 7
knob.Parent = base
round(knob)
function S.visual()
local o = g("Opacity")
if editMode then o = math.max(o, 0.45) end
base.BackgroundTransparency = 1 - o
knob.BackgroundTransparency = 1 - math.min(1, o + 0.25)
if not compass then
baseStroke.Color = editMode and BLUE or WHITE
baseStroke.Transparency = editMode and 0 or (1 - math.min(1, o + 0.1))
return
end
local col = pressColor(g("Color"))
baseStroke.Enabled = g("Stroke") == 1 or editMode
baseStroke.Thickness = g("StrokeW")
baseStroke.Color = editMode and BLUE or WHITE
baseStroke.Transparency = editMode and 0 or (1 - math.min(1, o + 0.1))
knob.Visible = g("KnobOn") == 1 or editMode
local lop = g("LetterOp")
if editMode then lop = math.max(lop, 0.45) end
local showText = g("Letters") == 1 or editMode
for i, lab in ipairs(labels) do
if not showText then
lab.TextTransparency = 1
elseif S.sector == i then
lab.TextTransparency = 0
lab.TextColor3 = col
else
lab.TextTransparency = 1 - lop
lab.TextColor3 = LETTER_IDLE
end
end
for _, l in ipairs(lines) do
l.BackgroundTransparency = 1 - math.min(1, o * 0.9)
end
end
function S.layout()
clampPos(p .. "X", p .. "Y", g("Size"))
local s = g("Size")
base.Visible = g("On") == 1
base.Size = UDim2.fromOffset(s, s)
base.Position = UDim2.fromScale(g("X"), g("Y"))
if not compass then
local k = math.floor(s * 0.42)
knob.Size = UDim2.fromOffset(k, k)
S.visual()
return
end
corner.CornerRadius = UDim.new(g("Round"), 0)
local k = math.floor(s * g("Knob"))
knob.Size = UDim2.fromOffset(k, k)
local r = s / 2
local n = g("Dirs")
-- буквы: основные (W A S D) обычные, диагонали меньше
local ls = s * g("LetterSize")
local ds = g("DiagScale")
for i, sec in ipairs(SECT) do
local lab = labels[i]
lab.Visible = (n == 8) or not sec.diag
if sec.diag then
local h = ls * ds
lab.Size = UDim2.fromOffset(h * 2.4, h)
else
lab.Size = UDim2.fromOffset(ls, ls)
end
local v = dirOf(sec.ang)
local d = r * g("LetterDist")
lab.Position = UDim2.new(0.5, v.X * d, 0.5, v.Y * d)
end
-- разделители
local angles = (n == 8) and { 22.5, 67.5, 112.5, 157.5 } or { 45, 135 }
for k2 = 1, 4 do
local l = lines[k2]
if angles[k2] and g("Lines") == 1 then
l.Visible = true
l.Rotation = angles[k2]
l.Size = UDim2.fromOffset(2, s - 6)
else
l.Visible = false
end
end
S.visual()
end
function S.reset()
S.axis = Vector2.zero
knob.Position = UDim2.fromScale(0.5, 0.5)
S.sector = nil
S.visual()
end
local function update(input)
local radius = base.AbsoluteSize.X / 2
if radius <= 0 then return end
local pos = Vector2.new(input.Position.X, input.Position.Y)
local delta = pos - S.origin
-- в режиме «направление по касанию» нейтраль не двигается
if g("TapDir") ~= 1 and g("Follow") == 1 and delta.Magnitude > radius then
S.origin = pos - delta.Unit * radius
delta = pos - S.origin
end
local mag = math.min(delta.Magnitude, radius)
local dir = delta.Magnitude > 0 and delta.Unit or Vector2.zero
local newSector = nil
if mag / radius < g("Deadzone") then
S.axis = Vector2.zero
else
S.axis = dir
if compass then
newSector = sectorOf(dir, g("Dirs"), S.sector, g("Hys"))
if g("Snap") == 1 then
S.axis = dirOf(SECT[newSector].ang)
end
end
end
local kdir = dir
if compass and g("KnobSnap") == 1 and newSector then
kdir = dirOf(SECT[newSector].ang)
end
knob.Position = UDim2.new(0.5, kdir.X * mag, 0.5, kdir.Y * mag)
if compass and newSector ~= S.sector then
S.sector = newSector
S.visual()
end
end
bindDrag(base,
function(i)
if editMode or g("On") ~= 1 then return false end
if g("TapDir") == 1 then
S.origin = objCenter(base) -- нейтраль = центр круга, касание сразу задаёт направление
elseif g("Adaptive") == 1 then
S.origin = Vector2.new(i.Position.X, i.Position.Y)
else
S.origin = objCenter(base)
end
end,
update,
S.reset)
makeMover(base, p .. "X", p .. "Y")
return S
end
local stick1 = newStick("", false)
local stick2 = newStick("S2_", true)
---------------------------------------------------------------- кнопки направлений
local btns = {}
for _, k in ipairs(KEYS) do
local f = Instance.new("Frame")
f.Name = "Btn_" .. k.id
f.AnchorPoint = Vector2.new(0.5, 0.5)
f.BackgroundColor3 = DARK
f.BorderSizePixel = 0
f.Active = true
f.Parent = gui
local corner = round(f, UDim.new(0.2, 0))
local st = stroke(f, WHITE, 0.5, 1.5)
local l = Instance.new("TextLabel")
l.BackgroundTransparency = 1
l.AnchorPoint = Vector2.new(0.5, 0.5)
l.Position = UDim2.fromScale(0.5, 0.5)
l.Size = UDim2.fromScale(0.7, 0.4)
l.Font = Enum.Font.GothamBold
l.TextScaled = true
l.TextColor3 = WHITE
l.Text = k.text
l.Parent = f
btns[k.id] = { frame = f, label = l, stroke = st, corner = corner, dir = k.dir, key = k }
end
local function btnVisual()
local bo = cfg.BtnOpacity
if editMode then bo = math.max(bo, 0.45) end
local tBase = 1 - bo
local tTop = 1 - math.min(1, bo * 1.4)
local tLine = 1 - math.min(1, bo * 1.1)
local col = pressColor(cfg.BtnColor)
for id, b in pairs(btns) do
local on = pressed[id]
b.frame.BackgroundColor3 = on and col or DARK
b.frame.BackgroundTransparency = on and tTop or tBase
b.label.TextTransparency = tTop
b.label.Visible = cfg.BtnLabels == 1 or editMode
b.label.TextColor3 = (on and col == WHITE) and DARK or WHITE
local picked = selectMode and id == selId
b.stroke.Enabled = cfg.BtnStroke == 1 or editMode or picked
b.stroke.Color = picked and YELLOW or (editMode and BLUE or WHITE)
b.stroke.Transparency = (picked or editMode) and 0 or tLine
end
end
local function btnPx(id)
return math.floor(cfg.BtnSize * cfg[K(id, "Scale")] + 0.5)
end
local function btnLayout()
for _, k in ipairs(KEYS) do
local b = btns[k.id]
local s = btnPx(k.id)
clampPos(K(k.id, "X"), K(k.id, "Y"), s)
b.frame.Size = UDim2.fromOffset(s, s)
b.frame.Position = UDim2.fromScale(cfg[K(k.id, "X")], cfg[K(k.id, "Y")])
b.frame.Visible = cfg[K(k.id, "On")] == 1
b.corner.CornerRadius = UDim.new(cfg.BtnRound, 0)
end
btnVisual()
end
function applyLayout()
stick1.layout()
stick2.layout()
btnLayout()
end
function applyVisual()
stick1.visual()
stick2.visual()
btnVisual()
end
local function clearButtons()
pressed = {}
applyVisual()
end
for _, k in ipairs(KEYS) do
local f = btns[k.id].frame
bindDrag(f,
function()
if editMode then return false end
if cfg.BtnLatch == 1 then
pressed[k.id] = (not pressed[k.id]) or nil
applyVisual()
return false
end
pressed[k.id] = true
applyVisual()
end,
function() end,
function()
pressed[k.id] = nil
applyVisual()
end)
makeMover(f, K(k.id, "X"), K(k.id, "Y"), k.id)
end
applyLayout()
---------------------------------------------------------------- движение
local curMove = Vector2.zero
-- приоритет: кнопки → стик 2 → стик 1
RunService:BindToRenderStep("NyxJoystick", Enum.RenderPriority.Input.Value + 1, function()
local sum = Vector2.zero
for id in pairs(pressed) do
sum += btns[id].dir
end
if sum.Magnitude > 0 then
curMove = sum.Unit
elseif stick2.axis.Magnitude > 0 then
curMove = stick2.axis
else
curMove = stick1.axis
end
local char = lp.Character
local hum = char and char:FindFirstChildOfClass("Humanoid")
if hum then
hum:Move(Vector3.new(curMove.X, 0, curMove.Y), true) -- относительно камеры
end
end)
-- прячем стоковый стик, прыжок остаётся
local hidden = {}
local alive = true
-- ранняя очистка: финальная версия ниже её перезапишет, но если скрипт упадёт посередине, эта останется
if getgenv then
getgenv().__NyxJoystickCleanup = function()
alive = false
pcall(function() RunService:UnbindFromRenderStep("NyxJoystick") end)
for _, c in ipairs(conns) do pcall(function() c:Disconnect() end) end
pcall(function() gui:Destroy() end)
end
end
task.spawn(function()
while alive do
pcall(function()
local pg = lp:FindFirstChild("PlayerGui")
local tg = pg and pg:FindFirstChild("TouchGui")
local tcf = tg and tg:FindFirstChild("TouchControlFrame")
if tcf then
for _, n in ipairs({ "ThumbstickFrame", "DynamicThumbstickFrame" }) do
local f = tcf:FindFirstChild(n)
if f and f.Visible then
hidden[f] = true
f.Visible = false
end
end
end
end)
task.wait(0.5)
end
end)
---------------------------------------------------------------- шестерёнка (перетаскивается)
local gear = Instance.new("TextButton")
gear.Size = UDim2.fromOffset(44, 44)
gear.AnchorPoint = Vector2.new(0.5, 0.5)
gear.Position = UDim2.fromScale(cfg.GearX, cfg.GearY)
gear.BackgroundColor3 = DARK
gear.BackgroundTransparency = 0.4
gear.Text = "⚙"
gear.TextColor3 = WHITE
gear.TextSize = 24
gear.AutoButtonColor = false
gear.Parent = gui
round(gear)
stroke(gear, WHITE, 0.5, 2)
local gearMoved, gStart, gPos = false, Vector2.zero, Vector2.zero
bindDrag(gear,
function(i)
gearMoved = false
gStart = Vector2.new(i.Position.X, i.Position.Y)
gPos = Vector2.new(cfg.GearX, cfg.GearY)
end,
function(i)
local d = Vector2.new(i.Position.X, i.Position.Y) - gStart
if d.Magnitude > 6 then
gearMoved = true
local v = gui.AbsoluteSize
cfg.GearX = math.clamp(gPos.X + d.X / v.X, 0.04, 0.96)
cfg.GearY = math.clamp(gPos.Y + d.Y / v.Y, 0.06, 0.94)
gear.Position = UDim2.fromScale(cfg.GearX, cfg.GearY)
end
end,
function() if gearMoved then saveCfg() end end)
---------------------------------------------------------------- панель
local PANEL_W, PANEL_H = 300, 462
local panel = Instance.new("Frame")
panel.Size = UDim2.fromOffset(PANEL_W, PANEL_H)
panel.AnchorPoint = Vector2.new(0.5, 0.5)
panel.Position = UDim2.fromScale(cfg.PanelX, cfg.PanelY)
panel.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
panel.BackgroundTransparency = 0.08
panel.Active = true
panel.Visible = false
panel.ZIndex = 10
panel.Parent = gui
round(panel, UDim.new(0, 12))
stroke(panel, WHITE, 0.7, 1)
local panelScale = Instance.new("UIScale", panel)
local function fitPanel()
local v = gui.AbsoluteSize
panelScale.Scale = math.clamp((v.Y - 10) / PANEL_H, 0.5, 1)
end
fitPanel()
local function label(parent, text, y, size, xAlign)
local l = Instance.new("TextLabel")
l.BackgroundTransparency = 1
l.Position = UDim2.fromOffset(12, y)
l.Size = UDim2.new(1, -24, 0, size or 18)
l.Font = Enum.Font.GothamBold
l.TextSize = 13
l.TextColor3 = WHITE
l.TextXAlignment = xAlign or Enum.TextXAlignment.Left
l.Text = text
l.ZIndex = 11
l.Parent = parent
return l
end
local pct = function(v) return math.floor(v * 100 + 0.5) .. "%" end
local px = function(v) return tostring(v) .. " px" end
local f2 = function(v) return string.format("%.2f", v) end
local f1 = function(v) return string.format("%.1f", v) end
local int = function(v) return tostring(math.floor(v + 0.5)) end
local r2 = function(v) return math.floor(v * 100 + 0.5) / 100 end
---------------- окошко подсказки (?)
local helpPopup = Instance.new("Frame")
helpPopup.Position = UDim2.fromOffset(12, 104)
helpPopup.Size = UDim2.new(1, -24, 0, 176)
helpPopup.BackgroundColor3 = Color3.fromRGB(35, 35, 42)
helpPopup.Active = true
helpPopup.Visible = false
helpPopup.ZIndex = 30
helpPopup.Parent = panel
round(helpPopup, UDim.new(0, 10))
stroke(helpPopup, BLUE, 0.3, 1.5)
local popTitle = label(helpPopup, "", 8, 18)
popTitle.TextSize = 14
popTitle.TextColor3 = BLUE
popTitle.ZIndex = 31
local popBody = label(helpPopup, "", 30, 100)
popBody.Size = UDim2.new(1, -24, 1, -56)
popBody.Font = Enum.Font.Gotham
popBody.TextSize = 12
popBody.TextWrapped = true
popBody.TextYAlignment = Enum.TextYAlignment.Top
popBody.TextColor3 = Color3.fromRGB(225, 225, 225)
popBody.ZIndex = 31
local popHint = label(helpPopup, "нажми, чтобы закрыть", 154, 16, Enum.TextXAlignment.Right)
popHint.Font = Enum.Font.Gotham
popHint.TextSize = 10
popHint.TextColor3 = Color3.fromRGB(130, 130, 130)
popHint.ZIndex = 31
local helpOwner = nil
local function hideHelp()
helpPopup.Visible = false
helpOwner = nil
end
onTap(helpPopup, hideHelp)
local function showHelp(name, text)
if helpPopup.Visible and helpOwner == name then return hideHelp() end
helpOwner = name
popTitle.Text = name
popBody.Text = text
helpPopup.Visible = true
end
-- серый кружок со знаком вопроса
local function makeHelp(parent, x, y, name, text)
local h = Instance.new("TextButton")
h.Size = UDim2.fromOffset(22, 22)
h.Position = UDim2.new(x.X.Scale, x.X.Offset, 0, y)
h.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
h.Text = "?"
h.TextColor3 = Color3.fromRGB(190, 190, 190)
h.Font = Enum.Font.GothamBold
h.TextSize = 13
h.AutoButtonColor = false
h.ZIndex = 12
h.Parent = parent
round(h)
onTap(h, function() showHelp(name, text) end)
return h
end
local HELP_X = UDim2.new(1, -36, 0, 0)
---------------- ползунок: хватается только за ручку, тап по полосе ставит значение
local function makeSlider(parent, title, y, min, max, getv, setv, fmt)
local lbl = label(parent, "", y)
lbl.Size = UDim2.new(1, -50, 0, 18)
local hit = Instance.new("Frame")
hit.BackgroundTransparency = 1
hit.Position = UDim2.fromOffset(12, y + 20)
hit.Size = UDim2.new(1, -24, 0, 28)
hit.ZIndex = 11
hit.Parent = parent
local track = Instance.new("Frame")
track.Position = UDim2.new(0, 0, 0.5, -3)
track.Size = UDim2.new(1, 0, 0, 6)
track.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
track.BorderSizePixel = 0
track.ZIndex = 11
track.Parent = hit
round(track)
local fill = Instance.new("Frame")
fill.BackgroundColor3 = BLUE
fill.BorderSizePixel = 0
fill.ZIndex = 12
fill.Parent = track
round(fill)
local handle = Instance.new("Frame")
handle.Size = UDim2.fromOffset(18, 18)
handle.AnchorPoint = Vector2.new(0.5, 0.5)
handle.BackgroundColor3 = WHITE
handle.BorderSizePixel = 0
handle.ZIndex = 13
handle.Parent = track
round(handle)
-- расширенная зона захвата вокруг ручки
local grab = Instance.new("Frame")
grab.BackgroundTransparency = 1
grab.AnchorPoint = Vector2.new(0.5, 0.5)
grab.Position = UDim2.fromScale(0.5, 0.5)
grab.Size = UDim2.fromOffset(40, 40)
grab.Active = true -- только здесь касание не прокручивает меню
grab.ZIndex = 14
grab.Parent = handle
local function refresh()
local v = getv()
local a = math.clamp((v - min) / (max - min), 0, 1)
fill.Size = UDim2.fromScale(a, 1)
handle.Position = UDim2.new(a, 0, 0.5, 0)
local t = type(title) == "function" and title() or title
lbl.Text = t .. ": " .. fmt(v)
end
local function setFromX(x)
local a = math.clamp((x - track.AbsolutePosition.X) / track.AbsoluteSize.X, 0, 1)
setv(min + (max - min) * a)
refresh()
end
bindDrag(grab, nil, function(i) setFromX(i.Position.X) end, saveCfg)
onTap(hit, function(i) setFromX(i.Position.X); saveCfg() end)
refresh()
return refresh
end
---------------- заголовок панели (тащи, чтобы двигать)
local titleLabel = label(panel, "Настройки (тащи за заголовок)", 8, 20, Enum.TextXAlignment.Center)
titleLabel.Active = true
local pStart, pPos = Vector2.zero, Vector2.zero
bindDrag(titleLabel,
function(i)
pStart = Vector2.new(i.Position.X, i.Position.Y)
pPos = Vector2.new(cfg.PanelX, cfg.PanelY)
end,
function(i)
local d = Vector2.new(i.Position.X, i.Position.Y) - pStart
local v = gui.AbsoluteSize
cfg.PanelX = math.clamp(pPos.X + d.X / v.X, 0.2, 0.8)
cfg.PanelY = math.clamp(pPos.Y + d.Y / v.Y, 0.2, 0.8)
panel.Position = UDim2.fromScale(cfg.PanelX, cfg.PanelY)
end,
saveCfg)
local function rowButton(parent, text, y, h)
local b = Instance.new("TextButton")
b.Position = UDim2.fromOffset(12, y)
b.Size = UDim2.new(1, -50, 0, h or 32)
b.BackgroundColor3 = GREY
b.Text = text
b.TextColor3 = WHITE
b.Font = Enum.Font.GothamBold
b.TextSize = 12
b.AutoButtonColor = true
b.ZIndex = 11
b.Parent = parent
round(b, UDim.new(0, 8))
return b
end
local refreshers = {}
local togList = {}
local refreshToggles
-- Как в Meitnerium Mini: параметры действуют до перезапуска.
local extras = { jump = false, lines = false, distance = 50 }
local OPTAPI = {
refresh = function() end,
fps = function() end,
now = function() end,
undoAll = function() end,
}
local function onoff(b, text, v, color)
b.Text = text .. ": " .. (v == 1 and "ВКЛ" or "ВЫКЛ")
b.BackgroundColor3 = v == 1 and (color or ON) or GREY
end
-- конструктор страницы: элементы встают друг под другом сами
local function newPage()
local sf = Instance.new("ScrollingFrame")
sf.BackgroundTransparency = 1
sf.BorderSizePixel = 0
sf.Position = UDim2.fromOffset(0, 104)
sf.Size = UDim2.new(1, 0, 0, 258)
sf.CanvasSize = UDim2.fromOffset(0, 0)
sf.ScrollBarThickness = 4
sf.ScrollingDirection = Enum.ScrollingDirection.Y
sf.ZIndex = 11
sf.Parent = panel
local P = { frame = sf, y = 4 }
function P.header(text)
local l = label(sf, text, P.y + 2, 16)
l.TextColor3 = BLUE
l.TextSize = 12
P.y += 24
end
function P.slider(name, help, min, max, getv, setv, fmt, dyn)
local refresh = makeSlider(sf, dyn or name, P.y, min, max, getv, setv, fmt)
makeHelp(sf, HELP_X, P.y - 2, name, help)
table.insert(refreshers, refresh)
P.y += 54
return refresh
end
function P.toggle(name, help, key, after, color)
local b = rowButton(sf, "", P.y)
makeHelp(sf, HELP_X, P.y + 5, name, help)
table.insert(togList, { btn = b, name = name, key = key, color = color })
onTap(b, function()
cfg[key] = 1 - cfg[key]
if after then after() end
applyLayout()
refreshToggles()
saveCfg()
end)
P.y += 38
return b
end
function P.action(name, help, fn)
local b = rowButton(sf, name, P.y)
makeHelp(sf, HELP_X, P.y + 5, name, help)
onTap(b, fn)
P.y += 38
return b
end
function P.finish()
sf.CanvasSize = UDim2.fromOffset(0, P.y + 8)
end
return P
end
local function resetS1() stick1.reset() end
local function resetS2() stick2.reset() end
---------------- верх панели
local editBtn = rowButton(panel, "Перемещение: ВЫКЛ", 30, 34)
makeHelp(panel, HELP_X, 36, "Перемещение",
"Режим расстановки. Пока он включён, джойстики и кнопки не двигают персонажа, а перетаскиваются пальцем по экрану. Всё подсвечивается синим, даже если прозрачность 0%. Положение сохраняется само. Нажатие на кнопку в этом режиме выбирает её для настройки размера.")
---------------- вкладки (5 штук)
local TAB_W = 42
local tabs = {}
local function makeTab(i, text, name)
local b = Instance.new("TextButton")
b.Position = UDim2.fromOffset(12 + (i - 1) * (TAB_W + 4), 70)
b.Size = UDim2.fromOffset(TAB_W, 28)
b.BackgroundColor3 = GREY
b.Text = text
b.TextColor3 = WHITE
b.Font = Enum.Font.GothamBold
b.TextSize = 9
b.AutoButtonColor = true
b.ZIndex = 11
b.Parent = panel
round(b, UDim.new(0, 8))
tabs[name] = b
return b
end
makeTab(1, "Стик 1", "joy")
makeTab(2, "Стик 2", "cmp")
makeTab(3, "Вид 2", "vw")
makeTab(4, "Кнопки", "btn")
makeTab(5, "Луч", "ray")
makeTab(6, "Опт.", "opt")
local pages = {}
---------------- страница «Стик 1»
do
local P = newPage()
pages.joy = P
P.toggle("Стик 1 включён",
"Показывает или прячет обычный круглый джойстик. Когда выключен, он не реагирует на касания. Можно держать включёнными оба стика сразу.",
"On", resetS1)
P.slider("Размер",
"Диаметр основания джойстика. Большой стик точнее, но занимает больше места на экране.",
90, 300,
function() return cfg.Size end,
function(v) cfg.Size = math.floor(v + 0.5); applyLayout() end, px)
P.slider("Прозрачность",
"Насколько виден джойстик. 0% — невидим, но продолжает работать. В режиме «Перемещение» он всё равно подсвечивается.",
0, 1,
function() return cfg.Opacity end,
function(v) cfg.Opacity = r2(v); applyVisual() end, pct)
P.slider("Мёртвая зона",
"Область у нейтрали, где движение не считается. Убирает дрожание пальца. Для точных сетов подойдёт 2–6%.",
0, 0.3,
function() return cfg.Deadzone end,
function(v) cfg.Deadzone = r2(v) end, pct)
P.toggle("Направление по касанию",
"Нажми в любое место круга, и персонаж сразу идёт в ту сторону, где ты коснулся относительно центра. Тянуть от центра не нужно. Нейтраль всегда в центре круга, поэтому «Центр под палец» и «Центр следует» при этом не работают. Касание в самом центре (мёртвая зона) — стоишь.",
"TapDir", resetS1)
P.toggle("Центр под палец",
"Точка, куда ты положил палец, становится нейтралью. Не нужно попадать в центр круга: любой сдвиг от места касания даёт направление. Не работает, пока включено «Направление по касанию».",
"Adaptive")
P.toggle("Центр следует",
"Если палец ушёл дальше края круга, нейтраль подтягивается за ним. Так лёгкий сдвиг влево или вправо всегда даёт одинаково чуткий угол. Не работает, пока включено «Направление по касанию».",
"Follow")
P.finish()
end
---------------- страница «Стик 2» (поведение)
local dirsBtn, color2Btn
do
local P = newPage()
pages.cmp = P
P.toggle("Стик 2 включён",
"Включает круг с буквами W A S D и диагоналями. По умолчанию выключен. Включи и нажми «Перемещение», чтобы поставить его на удобное место.",
"S2_On", resetS2, GREEN)
P.slider("Размер",
"Диаметр круга. Чем больше, тем шире каждый сектор и тем легче попасть в нужное направление.",
100, 340,
function() return cfg.S2_Size end,
function(v) cfg.S2_Size = math.floor(v + 0.5); applyLayout() end, px)
P.slider("Мёртвая зона",
"Радиус в центре, внутри которого направление не выбирается. Касание в центре — стоишь.",
0, 0.5,
function() return cfg.S2_Deadzone end,
function(v) cfg.S2_Deadzone = r2(v) end, pct)
P.toggle("Направление по касанию",
"Нажми на букву (или рядом с ней), и персонаж сразу идёт в это направление. Тянуть от центра не нужно: направление определяется тем, где относительно центра ты коснулся. Нейтраль всегда в центре, поэтому «Центр под палец» и «Центр следует» при этом не работают. Включено по умолчанию.",
"S2_TapDir", resetS2)
P.toggle("Привязка к направлениям",
"Движение идёт строго по центру выбранного сектора. Если палец чуть дрожит внутри сектора, направление не плывёт. Выключи, чтобы угол был свободным и точным, а подсвечивалась ближайшая буква.",
"S2_Snap", resetS2)
dirsBtn = P.action("Направлений: 8",
"Переключает между 8 направлениями (W, A, S, D и 4 диагонали) и 4 направлениями (только W, A, S, D). В режиме 4 диагонали исчезают вместе с буквами.",
function()
cfg.S2_Dirs = (cfg.S2_Dirs == 8) and 4 or 8
stick2.reset()
applyLayout()
refreshToggles()
saveCfg()
end)
P.slider("Залипание сектора",
"Запас в градусах на границе секторов. Пока палец не зашёл за границу на это значение, прежний сектор остаётся. Убирает дёргание между W и W+D при скольжении пальца. 0 — выключено, 3–8° — комфортно.",
0, 20,
function() return cfg.S2_Hys end,
function(v) cfg.S2_Hys = math.floor(v + 0.5) end,
function(v) return int(v) .. "°" end)
P.toggle("Центр под палец",
"Нейтраль там, куда лёг палец. Работает только если «Направление по касанию» выключено.",
"S2_Adaptive")
P.toggle("Центр следует",
"Если палец ушёл за край круга, нейтраль подтягивается за ним. Работает только если «Направление по касанию» выключено.",
"S2_Follow")
P.finish()
end
---------------- страница «Вид 2»
do
local P = newPage()
pages.vw = P
P.header("Круг")
P.slider("Прозрачность",
"Видимость заливки круга. 0% — круг невидим, но работает.",
0, 1,
function() return cfg.S2_Opacity end,
function(v) cfg.S2_Opacity = r2(v); applyVisual() end, pct)
P.slider("Скругление",
"Форма: от квадрата (0%) до идеального круга (100%).",
0, 0.5,
function() return cfg.S2_Round end,
function(v) cfg.S2_Round = r2(v); applyLayout() end,
function(v) return pct(v * 2) end)
P.toggle("Обводка",
"Белая рамка вокруг круга. Помогает видеть границу, когда заливка почти прозрачная.",
"S2_Stroke")
P.slider("Толщина обводки",
"Толщина рамки в пикселях.",
1, 6,
function() return cfg.S2_StrokeW end,
function(v) cfg.S2_StrokeW = math.floor(v + 0.5); applyVisual() end, px)
P.toggle("Разделители",
"Тонкие линии между секторами. По умолчанию выключены, чтобы круг был чистым.",
"S2_Lines")
P.header("Буквы")
P.toggle("Буквы",
"Подписи направлений: W, A, S, D и диагонали. Без фона, только текст. Активная буква подсвечивается цветом.",
"S2_Letters")
P.slider("Размер основных (WASD)",
"Размер букв W, A, S, D относительно круга.",
0.12, 0.4,
function() return cfg.S2_LetterSize end,
function(v) cfg.S2_LetterSize = r2(v); applyLayout() end, pct)
P.slider("Размер диагоналей",
"Размер букв W+A, W+D, S+A, S+D относительно основных. 100% — одинаковые, меньше — диагонали мельче.",
0.3, 1,
function() return cfg.S2_DiagScale end,
function(v) cfg.S2_DiagScale = r2(v); applyLayout() end, pct)
P.slider("Дальность букв",
"Как далеко от центра стоят буквы. Больше — ближе к краю, меньше — ближе к центру.",
0.45, 0.95,
function() return cfg.S2_LetterDist end,
function(v) cfg.S2_LetterDist = r2(v); applyLayout() end, pct)
P.slider("Прозрачность букв",
"Видимость текста неактивных букв. Активная буква всегда видна полностью.",
0, 1,
function() return cfg.S2_LetterOp end,
function(v) cfg.S2_LetterOp = r2(v); applyVisual() end, pct)
color2Btn = P.action("Цвет активной буквы",
"Цвет буквы, в чьём секторе сейчас палец. Нажимай, чтобы листать 6 вариантов: синий, зелёный, красный, белый, фиолетовый, жёлтый.",
function()
cfg.S2_Color = cfg.S2_Color % #PRESS_COLORS + 1
refreshToggles()
applyVisual()
saveCfg()
end)
P.header("Точка в центре")
P.toggle("Точка (ручка)",
"Круглая точка в центре, как в первом стике. Едет за пальцем. Можно спрятать, если хватает подсветки буквы.",
"S2_KnobOn")
P.slider("Размер точки",
"Диаметр точки относительно круга. 42% — как в первом стике.",
0.1, 0.7,
function() return cfg.S2_Knob end,
function(v) cfg.S2_Knob = r2(v); applyLayout() end, pct)
P.toggle("Точка в сектор",
"Точка прыгает в центр выбранного сектора вместо того, чтобы точно следовать за пальцем.",
"S2_KnobSnap")
P.finish()
end
---------------- страница «Кнопки»
local gridCells, modeBtn, allBtn, colorBtn
local refreshScale
do
local P = newPage()
pages.btn = P
local sf = P.frame
P.slider("Размер кнопок",
"Общий размер всех кнопок направлений. Размер отдельной кнопки можно изменить ниже.",
30, 140,
function() return cfg.BtnSize end,
function(v) cfg.BtnSize = math.floor(v + 0.5); applyLayout() end, px)
P.slider("Прозрачность кнопок",
"Видимость кнопок. 0% — невидимы, но работают. Не зависит от прозрачности стиков.",
0, 1,
function() return cfg.BtnOpacity end,
function(v) cfg.BtnOpacity = r2(v); applyVisual() end, pct)
P.slider("Скругление",
"Форма кнопок: от квадрата (0%) до круга (100%).",
0, 0.5,
function() return cfg.BtnRound end,
function(v) cfg.BtnRound = r2(v); applyLayout() end,
function(v) return pct(v * 2) end)
P.toggle("Подписи",
"Буквы на кнопках (W, W+A и т. д.). Выключи для чистого вида, если ты и так знаешь раскладку.",
"BtnLabels")
P.toggle("Обводка",
"Рамка вокруг каждой кнопки.",
"BtnStroke")
P.toggle("Залипание",
"Тап включает кнопку, повторный тап выключает. Не нужно держать палец. Две кнопки можно включить вместе, они сложатся в диагональ.",
"BtnLatch", clearButtons)
colorBtn = P.action("Цвет нажатия",
"Цвет кнопки, пока она нажата. Листает 6 вариантов.",
function()
cfg.BtnColor = cfg.BtnColor % #PRESS_COLORS + 1
refreshToggles()
applyVisual()
saveCfg()
end)
-- сетка выбора
local gl = label(sf, "Сетка кнопок", P.y + 2, 16)
gl.Size = UDim2.new(1, -50, 0, 16)
makeHelp(sf, HELP_X, P.y - 2, "Сетка кнопок",
"Каждая клетка — одна кнопка. В режиме ПОКАЗ тап по клетке включает или выключает кнопку на экране. В режиме ВЫБОР тап выбирает кнопку, и ползунок «Размер выбранной» внизу меняет только её. Центральная клетка переключает режим.")
P.y += 24
local GRID_Y = P.y
gridCells = {}
local function gridBtn(c, r, text)
local b = Instance.new("TextButton")
b.Position = UDim2.fromOffset(12 + c * 93, GRID_Y + r * 28)
b.Size = UDim2.fromOffset(90, 25)
b.BackgroundColor3 = GREY
b.Text = text
b.TextColor3 = WHITE
b.Font = Enum.Font.GothamBold
b.TextSize = 12
b.AutoButtonColor = true
b.ZIndex = 11
b.Parent = sf
round(b, UDim.new(0, 8))
return b
end
for _, k in ipairs(KEYS) do
local b = gridBtn(k.c, k.r, k.text)
gridCells[k.id] = b
onTap(b, function()
if selectMode then
selId = k.id
onSelect()
else
cfg[K(k.id, "On")] = 1 - cfg[K(k.id, "On")]
pressed[k.id] = nil
applyLayout()
refreshToggles()
saveCfg()
end
end)
end
modeBtn = gridBtn(1, 1, "")
onTap(modeBtn, function()
selectMode = not selectMode
refreshToggles()
applyVisual()
end)
P.y += 90
allBtn = P.action("Показать все кнопки",
"Включает все 8 кнопок разом. Если все уже видны, прячет их все.",
function()
local all = true
for _, k in ipairs(KEYS) do
if cfg[K(k.id, "On")] ~= 1 then all = false end
end
for _, k in ipairs(KEYS) do
cfg[K(k.id, "On")] = all and 0 or 1
end
pressed = {}
applyLayout()
refreshToggles()
saveCfg()
end)
refreshScale = P.slider("Размер выбранной",
"Индивидуальный размер той кнопки, которая выбрана (режим ВЫБОР в сетке или касание кнопки в режиме «Перемещение»). От 0.4× до 2.5× от общего размера.",
0.4, 2.5,
function() return cfg[K(selId, "Scale")] end,
function(v) cfg[K(selId, "Scale")] = math.floor(v * 20 + 0.5) / 20; applyLayout() end,
function(v) return string.format("%.2fx", v) end,
function() return "Размер выбранной (" .. btns[selId].key.text .. ")" end)
P.finish()
end
---------------- страница «Луч»
do
local P = newPage()
pages.ray = P
local function featureToggle(title, help, key, set)
local button
button = P.action(title, help, function()
extras[set](not extras[key])
onoff(button, title, extras[key] and 1 or 0)
end)
onoff(button, title, 0)
end
featureToggle("Directional Jump",
"При запросе прыжка через 0,03 с разворачивает персонажа по горизонтальному направлению камеры. При выключении возвращает автоповорот.",
"jump", "setJump")
featureToggle("Player Lines",
"Разноцветные линии из головы игроков другой команды в направлении их взгляда. Игроки с той же командой не отображаются.",
"lines", "setLines")
local distanceLabel = label(P.frame, "Line Dist", P.y + 6, 28)
distanceLabel.Size = UDim2.fromOffset(105, 28)
local distanceValue = label(P.frame, tostring(extras.distance), P.y + 6, 28, Enum.TextXAlignment.Center)
distanceValue.Position = UDim2.fromOffset(165, P.y + 6)
distanceValue.Size = UDim2.fromOffset(40, 28)
local function distanceButton(text, x, step)
local button = rowButton(P.frame, text, P.y + 6, 28)
button.Position = UDim2.fromOffset(x, P.y + 6)
button.Size = UDim2.fromOffset(32, 28)
onTap(button, function()
extras.distance = math.clamp(extras.distance + step, 0, 100)
distanceValue.Text = tostring(extras.distance)
end)
end
distanceButton("-", 133, -10)
distanceButton("+", 205, 10)
P.y += 44
P.header("Ball Predict")
P.toggle("Предикт линии",
"Рисует в мире линию вперёд от персонажа, пока он в прыжке. Направление берётся из того, куда ты сейчас ведёшь стик или жмёшь кнопки, так видно, куда полетит сет.",
"PredictOn", nil, GREEN)
P.slider("Длина луча",
"Длина линии в стадах (studs).",
10, 250,
function() return cfg.RayLength end,
function(v) cfg.RayLength = math.floor(v + 0.5) end,
function(v) return tostring(v) .. " st" end)
P.slider("Толщина линии",
"Ширина линии луча.",
0.05, 1,
function() return cfg.LineWidth end,
function(v) cfg.LineWidth = r2(v) end, f2)
P.slider("Размер точки",
"Диаметр круглой метки в конце луча.",
0.5, 5,
function() return cfg.MarkerSize end,
function(v) cfg.MarkerSize = math.floor(v * 10 + 0.5) / 10 end, f1)
P.slider("Цвет R",
"Красная составляющая цвета луча (0–255).",
0, 255,
function() return cfg.ColorR end,
function(v) cfg.ColorR = math.floor(v + 0.5) end, int)
P.slider("Цвет G",
"Зелёная составляющая цвета луча (0–255).",
0, 255,
function() return cfg.ColorG end,
function(v) cfg.ColorG = math.floor(v + 0.5) end, int)
P.slider("Цвет B",
"Синяя составляющая цвета луча (0–255).",
0, 255,
function() return cfg.ColorB end,
function(v) cfg.ColorB = math.floor(v + 0.5) end, int)
P.finish()
end
---------------- страница «Оптимизация»
do
local P = newPage()
pages.opt = P
local function R() OPTAPI.refresh() end
P.toggle("Оптимизация (всё)",
"Главный выключатель. Выключишь, и всё ниже вернётся как было. Отдельные пункты ниже можно включать и выключать по одному.",
"OptOn", R, GREEN)
P.header("Свет и графика")
P.toggle("Убрать тени",
"Отключает тени у объектов и глобальные тени. Выключи этот пункт, если хочешь вернуть тени.",
"OptShadows", R)
P.toggle("Убрать туман и атмосферу",
"Убирает туман и атмосферную дымку. Меньше нагрузка на видеочип.",
"OptAtmos", R)
P.toggle("Убрать пост-эффекты",
"Bloom, размытие, цветокоррекция, лучи солнца, глубина резкости.",
"OptPost", R)
P.toggle("Убрать отражения",
"Обнуляет блеск и отражения на объектах.",
"OptReflect", R)
P.toggle("Упростить воду",
"Убирает волны и отражения воды, если вода есть на карте.",
"OptWater", R)
P.toggle("Качество: минимум",
"Ставит минимальный уровень графики Roblox. Выключишь, и вернётся прежний уровень.",
"OptQuality", R)
P.header("Эффекты и текстуры")
P.toggle("Убрать частицы и следы",
"Выключает частицы, следы, дым, огонь, искры и лучи. Меньше нагрузка в розыгрышах.",
"OptEffects", R)
P.toggle("Скрыть декали и текстуры",
"Прячет декали и PBR-текстуры. Сильно снижает память. Если пропадёт нужная разметка, выключи, всё вернётся.",
"OptDecals", R)
P.toggle("Удалять насовсем",
"Вместо скрытия декали удаляются. Экономит больше памяти, но вернуть их можно только перезаходом в игру.",
"OptPurge")
P.toggle("Серые меши",
"Убирает текстуры с мешей. Игра станет серой, зато заметно легче. По умолчанию выключено.",
"OptMeshTex", R)
P.toggle("Простые меши",
"Снижает детализацию мешей (меньше полигонов).",
"OptMeshFid", R)
P.header("Звук, FPS и память")
P.toggle("Заглушить звуки",
"Обнуляет громкость всех звуков в мире. По умолчанию выключено.",
"OptSounds", R)
P.toggle("Лимит FPS",
"Ограничивает частоту кадров. Ровные 60 обычно меньше греют телефон, чем скачущие 90-120. Выключишь, вернётся 60.",
"OptFpsOn", R)
P.slider("Значение лимита",
"Максимум кадров в секунду для лимита выше.",
30, 120,
function() return cfg.OptFps end,
function(v) cfg.OptFps = math.clamp(math.floor(v / 5 + 0.5) * 5, 30, 120); OPTAPI.fps() end,
function(v) return tostring(v) .. " FPS" end)
P.toggle("Чистка памяти",
"Каждые 30 секунд чистит память. Если память выше порога, заново проходит по миру и убирает новое.",
"OptGC")
P.slider("Порог памяти",
"Когда память игры выше этого значения, оптимизация заново проходит по всем объектам.",
800, 3000,
function() return cfg.OptMemLimit end,
function(v) cfg.OptMemLimit = math.clamp(math.floor(v / 100 + 0.5) * 100, 800, 3000) end,
function(v) return tostring(v) .. " МБ" end)
local memBtn
local function memText()
return string.format("Память: %d МБ (нажми: очистить)",
math.floor(game:GetService("Stats"):GetTotalMemoryUsageMb() + 0.5))
end
memBtn = P.action("Память",
"Показывает, сколько памяти занимает игра. Нажми, чтобы очистить память прямо сейчас и обновить число.",
function()
OPTAPI.now()
memBtn.Text = memText()
task.delay(2, function() if memBtn.Parent then memBtn.Text = memText() end end)
end)
memBtn.Text = memText()
P.finish()
end
---------------- обновление переключателей
function refreshToggles()
for _, t in ipairs(togList) do
onoff(t.btn, t.name, cfg[t.key], t.color)
end
dirsBtn.Text = "Направлений: " .. cfg.S2_Dirs
dirsBtn.BackgroundColor3 = ON
local c2 = pressColor(cfg.S2_Color)
color2Btn.BackgroundColor3 = c2
color2Btn.TextColor3 = (c2 == WHITE) and DARK or WHITE
local cb = pressColor(cfg.BtnColor)
colorBtn.BackgroundColor3 = cb
colorBtn.TextColor3 = (cb == WHITE) and DARK or WHITE
local all = true
for _, k in ipairs(KEYS) do
local on = cfg[K(k.id, "On")] == 1
if not on then all = false end
local cell = gridCells[k.id]
if selectMode then
cell.BackgroundColor3 = (k.id == selId) and Color3.fromRGB(200, 150, 0) or GREY
else
cell.BackgroundColor3 = on and ON or GREY
end
end
modeBtn.Text = selectMode and "ВЫБОР ⇄" or "ПОКАЗ ⇄"
modeBtn.BackgroundColor3 = selectMode and Color3.fromRGB(200, 150, 0) or Color3.fromRGB(80, 80, 80)
allBtn.Text = all and "Скрыть все кнопки" or "Показать все кнопки"
allBtn.BackgroundColor3 = Color3.fromRGB(80, 80, 80)
end
refreshToggles()
onSelect = function()
refreshScale()
refreshToggles()
applyVisual()
end
---------------- вкладки: переключение
local function showTab(name)
hideHelp()
for n, pg in pairs(pages) do
pg.frame.Visible = (n == name)
end
for n, b in pairs(tabs) do
b.BackgroundColor3 = (n == name) and ON or GREY
end
end
showTab("joy")
for n, b in pairs(tabs) do
onTap(b, function() showTab(n) end)
end
---------------- нижние кнопки
local function bottomButton(text, x, y, w)
local b = Instance.new("TextButton")
b.Position = UDim2.fromOffset(x, y)
b.Size = UDim2.fromOffset(w, 34)
b.BackgroundColor3 = GREY
b.Text = text
b.TextColor3 = WHITE
b.Font = Enum.Font.GothamBold
b.TextSize = 12
b.AutoButtonColor = true
b.ZIndex = 11
b.Parent = panel
round(b, UDim.new(0, 8))
return b
end
local resetBtn = bottomButton("Сбросить", 12, 372, 112)
makeHelp(panel, UDim2.fromOffset(128, 0), 378, "Сбросить",
"Возвращает ВСЕ настройки, позиции и размеры к значениям по умолчанию. Стик 2 при этом снова выключается. Отменить нельзя.")
local closeBtn = bottomButton("Закрыть", 160, 372, 128)
local killBtn = bottomButton("KILL SCRIPT", 12, 414, PANEL_W - 24 - 38)
killBtn.BackgroundColor3 = Color3.fromRGB(140, 20, 20)
makeHelp(panel, HELP_X, 420, "KILL SCRIPT",
"Полностью выключает скрипт: убирает стики, кнопки, меню и луч, возвращает стоковое управление Роблокса. Чтобы запустить снова, выполни скрипт заново.")
local function setEdit(on)
editMode = on
stick1.reset()
stick2.reset()
clearButtons()
editBtn.Text = on and "Перемещение: ВКЛ (тяни элементы)" or "Перемещение: ВЫКЛ"
editBtn.BackgroundColor3 = on and ON or GREY
applyVisual()
end
onTap(editBtn, function() setEdit(not editMode) end)
onTap(resetBtn, function()
for k, v in pairs(DEFAULT) do cfg[k] = v end
gear.Position = UDim2.fromScale(cfg.GearX, cfg.GearY)
panel.Position = UDim2.fromScale(cfg.PanelX, cfg.PanelY)
pressed = {}
stick1.reset()
stick2.reset()
applyLayout()
for _, r in ipairs(refreshers) do r() end
refreshToggles()
saveCfg()
OPTAPI.refresh()
end)
local function closePanel()
hideHelp()
panel.Visible = false
selectMode = false
setEdit(false)
refreshToggles()
saveCfg()
end
onTap(closeBtn, closePanel)
table.insert(conns, gear.Activated:Connect(function()
if gearMoved then return end
if panel.Visible then closePanel() else panel.Visible = true end
end))
table.insert(conns, gui:GetPropertyChangedSignal("AbsoluteSize"):Connect(function()
applyLayout()
fitPanel()
end))
---------------------------------------------------------------- BALL PREDICT (луч направления в прыжке)
local linePart = Instance.new("Part")
linePart.Name = "BPPredictLine"
linePart.Anchored = true
linePart.CanCollide = false
linePart.CanQuery = false
linePart.CanTouch = false
linePart.Massless = true
linePart.CastShadow = false
linePart.Material = Enum.Material.Neon
linePart.Transparency = 1
linePart.Parent = WS.CurrentCamera
local circleMarker = Instance.new("Part")
circleMarker.Name = "BPPredictMarker"
circleMarker.Shape = Enum.PartType.Cylinder
circleMarker.Anchored = true
circleMarker.CanCollide = false
circleMarker.CanQuery = false
circleMarker.CanTouch = false
circleMarker.Massless = true
circleMarker.CastShadow = false
circleMarker.Material = Enum.Material.Neon
circleMarker.Transparency = 1
circleMarker.Parent = WS.CurrentCamera
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Exclude
local rayDown = Vector3.new(0, -50, 0)
local rot90 = CFrame.Angles(0, 0, math.rad(90))
local function hideRay()
linePart.Transparency = 1
circleMarker.Transparency = 1
end
local rConn = RunService.RenderStepped:Connect(function()
if cfg.PredictOn == 0 then return hideRay() end
local cam = WS.CurrentCamera
local char = lp.Character
local hum = char and char:FindFirstChildOfClass("Humanoid")
local root = char and char:FindFirstChild("HumanoidRootPart")
if not (cam and hum and root) then return hideRay() end
local state = hum:GetState()
if state ~= Enum.HumanoidStateType.Freefall and state ~= Enum.HumanoidStateType.Jumping then
return hideRay()
end
if linePart.Parent ~= cam then
linePart.Parent = cam
circleMarker.Parent = cam
end
rayParams.FilterDescendantsInstances = { char, cam }
local hit = WS:Raycast(root.Position, rayDown, rayParams)
local floorY = hit and hit.Position.Y or (root.Position.Y - 2.5)
local look = Vector3.new(root.CFrame.LookVector.X, 0, root.CFrame.LookVector.Z)
local dir = look.Magnitude > 0.01 and look.Unit or Vector3.new(0, 0, -1)
if curMove.Magnitude > 0.1 then
local cl = Vector3.new(cam.CFrame.LookVector.X, 0, cam.CFrame.LookVector.Z)
local cr = Vector3.new(cam.CFrame.RightVector.X, 0, cam.CFrame.RightVector.Z)
if cl.Magnitude > 0.01 then
local d = cl.Unit * (-curMove.Y) + cr * curMove.X
if d.Magnitude > 0.01 then dir = d.Unit end
end
end
local startPos = Vector3.new(root.Position.X, floorY + 0.1, root.Position.Z)
local endPos = startPos + dir * cfg.RayLength
local centerPos = startPos + dir * (cfg.RayLength / 2)
local color = Color3.fromRGB(cfg.ColorR, cfg.ColorG, cfg.ColorB)
linePart.Size = Vector3.new(cfg.LineWidth, 0.1, cfg.RayLength)
linePart.CFrame = CFrame.lookAt(centerPos, endPos)
linePart.Color = color
linePart.Transparency = 0.3
circleMarker.Size = Vector3.new(0.1, cfg.MarkerSize, cfg.MarkerSize)
circleMarker.CFrame = CFrame.new(endPos) * rot90
circleMarker.Color = color
circleMarker.Transparency = 0.3
end)
---------------------------------------------------------------- DIRECTIONAL JUMP + PLAYER LINES
-- DIRECTIONAL JUMP + PLAYER LINES: begin runtime
do
local jumpGeneration = 0
local jumpHumanoid
local function currentHumanoid()
local character = lp.Character
return character and character:FindFirstChildOfClass("Humanoid")
end
local function restoreJump()
if jumpHumanoid and jumpHumanoid.Parent then
jumpHumanoid.AutoRotate = true
end
jumpHumanoid = nil
end
function extras.setJump(enabled)
extras.jump = enabled
jumpGeneration = jumpGeneration + 1
if not enabled then
restoreJump()
local humanoid = currentHumanoid()
if humanoid then humanoid.AutoRotate = true end
end
end
table.insert(conns, lp.CharacterRemoving:Connect(function(character)
if jumpHumanoid and jumpHumanoid.Parent == character then restoreJump() end
end))
table.insert(conns, UIS.JumpRequest:Connect(function()
local character = lp.Character
local humanoid = character and character:FindFirstChildOfClass("Humanoid")
local root = character and character:FindFirstChild("HumanoidRootPart")
if extras.jump and humanoid and root then
local generation = jumpGeneration
task.defer(function()
task.wait(0.03)
if not alive or not extras.jump or generation ~= jumpGeneration
or lp.Character ~= character or humanoid.Parent ~= character or root.Parent ~= character then
return
end
local camera = WS.CurrentCamera
if not camera then return end
local look = camera.CFrame.LookVector
local dir = Vector3.new(look.X, 0, look.Z)
if dir.Magnitude > 0 then
root.CFrame = CFrame.lookAt(root.Position, root.Position + dir.Unit)
humanoid.AutoRotate = false
jumpHumanoid = humanoid
end
end)
elseif humanoid then
humanoid.AutoRotate = true
end
end))
local lines = {}
local owned = {}
local lineColors = {
Color3.fromRGB(255, 0, 0), Color3.fromRGB(0, 255, 0),
Color3.fromRGB(0, 0, 255), Color3.fromRGB(255, 165, 0),
Color3.fromRGB(128, 0, 128), Color3.fromRGB(255, 255, 0),
Color3.fromRGB(139, 0, 0), Color3.fromRGB(0, 100, 0),
}
function extras.owns(object)
return owned[object] == true
end
local function removeLine(player)
local data = lines[player]
if not data then return end
pcall(function() data.beam:Destroy() end)
pcall(function() data.target:Destroy() end)
pcall(function() data.attachment:Destroy() end)
owned[data.beam] = nil
owned[data.target] = nil
lines[player] = nil
end
function extras.setLines(enabled)
extras.lines = enabled
if not enabled then
for player in pairs(lines) do removeLine(player) end
end
end
local function updateLine(player, index)
if player == lp or player.Team == lp.Team then removeLine(player) return end
local character = player.Character
local head = character and character:FindFirstChild("Head")
local root = character and character:FindFirstChild("HumanoidRootPart")
if not head or not root then removeLine(player) return end
local data = lines[player]
if data and (data.attachment.Parent ~= head or data.beam.Parent ~= head or data.target.Parent ~= WS) then
removeLine(player)
data = nil
end
local endpoint = head.Position + root.CFrame.LookVector * extras.distance
if not data then
local attachment = Instance.new("Attachment")
attachment.Parent = head
local target = Instance.new("Part")
target.Name = "MeitneriumLineTarget"
target.Anchored = true
target.CanCollide = false
target.CanQuery = false
target.CanTouch = false
target.Transparency = 1
target.Size = Vector3.new(0.1, 0.1, 0.1)
target.Position = endpoint
owned[target] = true
target.Parent = WS
local targetAttachment = Instance.new("Attachment")
targetAttachment.Parent = target
local beam = Instance.new("Beam")
beam.Attachment0 = attachment
beam.Attachment1 = targetAttachment
beam.Width0 = 0.25
beam.Width1 = 0.25
beam.FaceCamera = true
beam.LightEmission = 1
beam.Transparency = NumberSequence.new(0.3)
beam.Color = ColorSequence.new(lineColors[((index - 1) % #lineColors) + 1])
owned[beam] = true
beam.Parent = head
lines[player] = { beam = beam, target = target, attachment = attachment }
else
data.target.Position = endpoint
end
end
table.insert(conns, RunService.RenderStepped:Connect(function()
if not alive or not extras.lines then return end
for index, player in ipairs(Players:GetPlayers()) do
updateLine(player, index)
end
end))
table.insert(conns, Players.PlayerRemoving:Connect(removeLine))
function extras.cleanup()
extras.jump = false
jumpGeneration = jumpGeneration + 1
restoreJump()
extras.setLines(false)
end
end
-- DIRECTIONAL JUMP + PLAYER LINES: end runtime
---------------------------------------------------------------- очистка
local function cleanup()
alive = false
pcall(function() RunService:UnbindFromRenderStep("NyxJoystick") end)
extras.cleanup()
pcall(function() rConn:Disconnect() end)
for _, c in ipairs(conns) do pcall(function() c:Disconnect() end) end
for f in pairs(hidden) do
if f.Parent then f.Visible = true end
end
pcall(function() linePart:Destroy() end)
pcall(function() circleMarker:Destroy() end)
pcall(OPTAPI.undoAll)
gui:Destroy()
end
onTap(killBtn, cleanup)
if getgenv then getgenv().__NyxJoystickCleanup = cleanup end
---------------------------------------------------------------- ОПТИМИЗАЦИЯ (движок)
-- Каждый пункт независим: включается и выключается отдельно, выключение возвращает исходные значения.
do
local Lighting = game:GetService("Lighting")
local Stats = game:GetService("Stats")
local E = {} -- исходные значения окружения
local function weak() return setmetatable({}, { __mode = "k" }) end
local function inChar(o)
local m = o:FindFirstAncestorOfClass("Model")
return m ~= nil and m:FindFirstChildOfClass("Humanoid") ~= nil
end
local function skip(o)
if extras.owns(o) then return true end
if o == linePart or o == circleMarker then return true end
if o:IsDescendantOf(gui) then return true end
local pg = lp:FindFirstChildOfClass("PlayerGui")
if pg and o:IsDescendantOf(pg) then return true end
return false
end
local FEATS = {}
local function feat(key, def)
def.key = key
def.saved = def.strong and {} or weak()
def.applied = false
table.insert(FEATS, def)
return def
end
local function restoreProp(s, prop)
for o, v in pairs(s) do
pcall(function() o[prop] = v end)
end
table.clear(s)
end
feat("OptShadows", {
env = function()
if E.shadows == nil then E.shadows = Lighting.GlobalShadows end
Lighting.GlobalShadows = false
end,
obj = function(o, s)
if o:IsA("BasePart") and o.CastShadow then
s[o] = true
o.CastShadow = false
end
end,
undo = function(s)
for o in pairs(s) do pcall(function() o.CastShadow = true end) end
table.clear(s)
if E.shadows ~= nil then Lighting.GlobalShadows = E.shadows end
end,
})
feat("OptAtmos", {
env = function()
if E.fogEnd == nil then E.fogEnd = Lighting.FogEnd end
Lighting.FogEnd = 9e9
end,
obj = function(o, s)
if o:IsA("Atmosphere") and o.Density > 0 then
s[o] = o.Density
o.Density = 0
end
end,
undo = function(s)
restoreProp(s, "Density")
if E.fogEnd ~= nil then Lighting.FogEnd = E.fogEnd end
end,
})
feat("OptPost", {
obj = function(o, s)
if o:IsA("PostEffect") and o.Enabled then
s[o] = true
o.Enabled = false
end
end,
undo = function(s)
for o in pairs(s) do pcall(function() o.Enabled = true end) end
table.clear(s)
end,
})
feat("OptReflect", {
obj = function(o, s)
if o:IsA("BasePart") and o.Reflectance > 0 then
s[o] = o.Reflectance
o.Reflectance = 0
end
end,
undo = function(s) restoreProp(s, "Reflectance") end,
})
feat("OptWater", {
env = function()
local t = WS:FindFirstChildOfClass("Terrain")
if not t then return end
if E.water == nil then
E.water = { t.WaterWaveSize, t.WaterWaveSpeed, t.WaterReflectance, t.WaterTransparency }
end
t.WaterWaveSize, t.WaterWaveSpeed = 0, 0
t.WaterReflectance, t.WaterTransparency = 0, 0
end,
undo = function()
local t = WS:FindFirstChildOfClass("Terrain")
if t and E.water then
t.WaterWaveSize, t.WaterWaveSpeed = E.water[1], E.water[2]
t.WaterReflectance, t.WaterTransparency = E.water[3], E.water[4]
end
end,
})
feat("OptQuality", {
env = function()
pcall(function()
local r = settings().Rendering
if E.quality == nil then E.quality = r.QualityLevel end
r.QualityLevel = Enum.QualityLevel.Level01
end)
end,
undo = function()
pcall(function()
if E.quality ~= nil then settings().Rendering.QualityLevel = E.quality end
end)
end,
})
local EFX = { ParticleEmitter = true, Trail = true, Smoke = true, Fire = true, Sparkles = true, Beam = true }
feat("OptEffects", {
obj = function(o, s)
if EFX[o.ClassName] and o.Enabled then
s[o] = true
o.Enabled = false
end
end,
undo = function(s)
for o in pairs(s) do pcall(function() o.Enabled = true end) end
table.clear(s)
end,
})
-- strong = true: скрытые декали держим в таблице, чтобы их можно было вернуть
feat("OptDecals", {
strong = true,
obj = function(o, s)
if (o:IsA("Decal") or o:IsA("SurfaceAppearance")) and o.Parent and not inChar(o) then
if cfg.OptPurge == 1 then
o:Destroy()
else
s[o] = o.Parent
o.Parent = nil
end
end
end,
undo = function(s)
for o, p in pairs(s) do
pcall(function() if p.Parent then o.Parent = p end end)
end
table.clear(s)
end,
})
feat("OptMeshTex", {
obj = function(o, s)
if o:IsA("MeshPart") and o.TextureID ~= "" and not inChar(o) then
s[o] = o.TextureID
o.TextureID = ""
end
end,
undo = function(s) restoreProp(s, "TextureID") end,
})
feat("OptMeshFid", {
env = function()
pcall(function()
local r = settings().Rendering
if E.meshDet == nil then E.meshDet = r.MeshPartDetailLevel end
r.MeshPartDetailLevel = Enum.MeshPartDetailLevel.Level04
end)
end,
obj = function(o, s)
if o:IsA("MeshPart") and o.RenderFidelity ~= Enum.RenderFidelity.Performance and not inChar(o) then
s[o] = o.RenderFidelity
o.RenderFidelity = Enum.RenderFidelity.Performance
end
end,
undo = function(s)
restoreProp(s, "RenderFidelity")
pcall(function()
if E.meshDet ~= nil then settings().Rendering.MeshPartDetailLevel = E.meshDet end
end)
end,
})
feat("OptSounds", {
obj = function(o, s)
if o:IsA("Sound") and o.Volume > 0 then
s[o] = o.Volume
o.Volume = 0
end
end,
undo = function(s) restoreProp(s, "Volume") end,
})
local fpsFeat = feat("OptFpsOn", {
env = function() pcall(function() setfpscap(cfg.OptFps) end) end,
undo = function() pcall(function() setfpscap(60) end) end,
})
------------------------------------------------ проход по миру
local lastPass = 0
local function dispatch(o)
if skip(o) then return end
for _, f in ipairs(FEATS) do
if f.applied and f.obj then pcall(f.obj, o, f.saved) end
end
end
local function startPass()
lastPass = os.clock()
task.spawn(function()
local n = 0
for _, o in ipairs(game:GetDescendants()) do
if not alive then return end
dispatch(o)
n += 1
if n % 150 == 0 then task.wait() end
end
end)
end
local function refresh()
local needPass = false
for _, f in ipairs(FEATS) do
local want = cfg.OptOn == 1 and cfg[f.key] == 1
if want and not f.applied then
f.applied = true
if f.env then pcall(f.env) end
if f.obj then needPass = true end
elseif not want and f.applied then
f.applied = false
if f.undo then pcall(f.undo, f.saved) end
end
end
if needPass then startPass() end
end
-- новые объекты, которые появляются во время игры
table.insert(conns, game.DescendantAdded:Connect(function(o)
if alive then task.defer(pcall, dispatch, o) end
end))
-- чистка памяти
task.spawn(function()
while alive do
task.wait(30)
if not alive then break end
if cfg.OptOn == 1 and cfg.OptGC == 1 then
pcall(function() collectgarbage("collect") end)
local mem = Stats:GetTotalMemoryUsageMb()
if mem > cfg.OptMemLimit and os.clock() - lastPass > 60 then startPass() end
end
end
end)
OPTAPI.refresh = refresh
OPTAPI.fps = function()
if fpsFeat.applied then pcall(function() setfpscap(cfg.OptFps) end) end
end
OPTAPI.now = function()
pcall(function() collectgarbage("collect") end)
startPass()
end
OPTAPI.undoAll = function()
for _, f in ipairs(FEATS) do
if f.applied then
f.applied = false
if f.undo then pcall(f.undo, f.saved) end
end
end
end
refresh()
end