Files
Fishing/tools/lobby-fix3.lua
T
2026-11-06 12:34:01 +05:00

166 lines
6.7 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- Правки лобби №3: новые скамейки и фонтан из Blockbench (порталы — нет: у моделей сломана арка).
-- Запуск: node tools/lobby-fix3.js <out.lua>, выполнить <out.lua> в Studio (режим редактирования), Ctrl+S.
-- Повторный запуск пересобирает: старое уже в ServerStorage.Backup.LobbyFix3, места берутся оттуда.
-- * 8 скамеек (Seat + ножки + спинка в FishingMap) → lobby_bench / lobby_bench_flowers через одну, на тех же местах,
-- лицом к центру; Seat (на нём сидят) остаётся, невидимый, на сиденье новой скамейки.
-- * Фонтан (Workspace["Low poly"]) и рыбка над ним → Backup; lobby_fountain по размеру старой чаши, между порталами,
-- вода — голубое стекло, на верхушке — струи частиц.
local ServerStorage = game:GetService("ServerStorage")
local map = workspace.FishingMap
local FLOOR = 1
local BENCH_SCALE = 1.2
local FOUNTAIN_SIZE = 15 -- ширина фонтана: чаша старого фонтана, порталы вокруг не задеваются
local report = {}
local backup = ServerStorage:FindFirstChild("Backup") or Instance.new("Folder")
backup.Name = "Backup"
backup.Parent = ServerStorage
local store = backup:FindFirstChild("LobbyFix3")
local first = store == nil
if first then
store = Instance.new("Folder")
store.Name = "LobbyFix3"
store.Parent = backup
end
local new = map:FindFirstChild("LobbyFix3")
if new then
new:Destroy()
end
new = Instance.new("Folder")
new.Name = "LobbyFix3"
new.Parent = map
local function anchorAll(m)
for _, p in ipairs(m:GetDescendants()) do
if p:IsA("BasePart") then
p.Anchored = true
end
end
end
---------------------------------------------------------------- скамейки
-- старые скамейки: Seat у площади и детали рядом (ножки, спинка)
local benches = {}
if first then
for _, s in ipairs(map:GetChildren()) do
if s:IsA("Seat") and Vector3.new(s.Position.X, 0, s.Position.Z).Magnitude < 60 then
local parts = {}
for _, c in ipairs(map:GetChildren()) do
if c:IsA("BasePart") and not c:IsA("Seat") and (c.Position - s.Position).Magnitude < 3.2 and c.Size.Magnitude < 6 then
table.insert(parts, c)
end
end
local f = Instance.new("Folder")
f.Name = "Bench"
f:SetAttribute("SeatCF", s.CFrame)
for _, p in ipairs(parts) do
p.Parent = f
end
s.Parent = f -- Seat вернём в карту ниже
f.Parent = store
end
end
end
for _, f in ipairs(store:GetChildren()) do
if f.Name == "Bench" then
table.insert(benches, f)
end
end
table.sort(benches, function(a, b)
local pa, pb = a:GetAttribute("SeatCF").Position, b:GetAttribute("SeatCF").Position
return math.atan2(pa.Z, pa.X) < math.atan2(pb.Z, pb.X)
end)
for i, f in ipairs(benches) do
local p = f:GetAttribute("SeatCF").Position
local at = Vector3.new(p.X, FLOOR, p.Z)
local m = (i % 2 == 1 and BUILD.bench or BUILD.bench_flowers)(new)
m.Name = "LobbyBench_" .. i
m:ScaleTo(BENCH_SCALE)
m:PivotTo(CFrame.lookAt(at, Vector3.new(0, FLOOR, 0)))
anchorAll(m)
-- сиденье (на нём сидят): невидимый Seat поверх досок скамейки
local seat = f:FindFirstChildOfClass("Seat") or map:FindFirstChild("LobbySeat_" .. i)
if seat then
seat = seat:IsDescendantOf(store) and seat:Clone() or seat
seat.Name = "LobbySeat_" .. i
seat.Transparency = 1
seat.Size = Vector3.new(5.8 * BENCH_SCALE, 0.3, 1.4 * BENCH_SCALE)
seat.CFrame = m:GetPivot() * CFrame.new(0, 1.55 * BENCH_SCALE, -0.27 * BENCH_SCALE)
seat.Anchored = true
seat.Parent = m
end
end
table.insert(report, "скамеек: " .. #benches)
---------------------------------------------------------------- фонтан
if first then
for _, o in ipairs({ workspace:FindFirstChild("Low poly"), map:FindFirstChild("Золотая рыбка") }) do
if o then
o:SetAttribute("Fix3OrigParent", o.Parent:GetFullName())
o.Parent = store
end
end
end
local f = BUILD.fountain(new)
f.Name = "LobbyFountain"
local _, size = f:GetBoundingBox()
f:ScaleTo(FOUNTAIN_SIZE / math.max(size.X, size.Z))
f:PivotTo(CFrame.new(0, FLOOR, 0) * CFrame.Angles(0, math.rad(45), 0)) -- фонари фонтана — по диагоналям, между порталами
anchorAll(f)
local water = f:FindFirstChild("Water")
for _, p in ipairs(water and water:GetDescendants() or {}) do
if p:IsA("BasePart") then
p.Material = Enum.Material.Glass
p.Color = Color3.fromRGB(110, 190, 235)
p.Transparency = 0.3
p.CanCollide = false
end
end
-- струи: частицы из верхушки, капли падают в чашу
local top = water and (water:FindFirstChild("JetA_Top") or water:FindFirstChild("JetA_Up"))
if top then
local pe = Instance.new("ParticleEmitter")
pe.Texture = "rbxasset://textures/particles/sparkles_main.dds"
pe.Color = ColorSequence.new(Color3.fromRGB(200, 235, 255))
pe.Size = NumberSequence.new({ NumberSequenceKeypoint.new(0, 0.35), NumberSequenceKeypoint.new(1, 0.15) })
pe.Transparency = NumberSequence.new({ NumberSequenceKeypoint.new(0, 0.2), NumberSequenceKeypoint.new(1, 1) })
pe.Lifetime = NumberRange.new(1.2, 1.6)
pe.Rate = 60
pe.Speed = NumberRange.new(5, 7)
pe.SpreadAngle = Vector2.new(35, 35)
pe.Acceleration = Vector3.new(0, -14, 0)
pe.EmissionDirection = Enum.NormalId.Top
pe.LightEmission = 0.4
pe.Parent = top
end
-- рыбка из старого фонтана — снова в чаше, на воде
local fish = store:FindFirstChild("Золотая рыбка")
local basin = water and water:FindFirstChild("Water_Basin_0")
if fish and basin then
local copy = fish:Clone()
local cf, s = copy:GetBoundingBox()
copy:ScaleTo(0.6)
copy:PivotTo(CFrame.new(-3.2, basin.Position.Y + 0.25, -3.2) * CFrame.Angles(0, math.rad(30), 0))
copy.Parent = f
end
-- проверка: фонтан не задевает порталы
local overlap = OverlapParams.new()
overlap.FilterType = Enum.RaycastFilterType.Exclude
overlap.FilterDescendantsInstances = { new }
local cf, sz = f:GetBoundingBox()
local hits = {}
for _, p in ipairs(workspace:GetPartBoundsInBox(cf, sz - Vector3.new(0.4, 0.4, 0.4), overlap)) do
if p.CanCollide and p.Position.Y > 1.2 then
hits[p.Parent and p.Parent.Name or p.Name] = true
end
end
local list = {}
for k in pairs(hits) do
table.insert(list, k)
end
table.insert(report, ("фонтан: %.1f × %.1f, задевает: %s"):format(sz.X, sz.Z, #list > 0 and table.concat(list, ", ") or "ничего"))
return table.concat(report, "\n")