diff --git a/src/community/docsGamesBuildersLua.js b/src/community/docsGamesBuildersLua.js index 400e659..5a05ec8 100644 --- a/src/community/docsGamesBuildersLua.js +++ b/src/community/docsGamesBuildersLua.js @@ -1191,37 +1191,88 @@ end)`, // ═══════════════════════════════════════════════════════════════ // ИГРА 14 — «Собери по тегу» // ═══════════════════════════════════════════════════════════════ - 'collect-by-tag': { - g14_main: `-- === ИГРА «СОБЕРИ ПО ТЕГУ» (Lua) === -local CollectionService = game:GetService("CollectionService") + 'collect-by-tag': (function() { + const TOTAL = 7; + const overrides = { + g14_main: `-- === ИГРА «СОБЕРИ ПО ТЕГАМ» — главный скрипт (Lua) === ${SNIPPET_BROADCAST} -local total = #CollectionService:GetTagged("звезда") -local collected = 0 -print("Собери все " .. total .. " звёзд!") +local CollectionService = game:GetService("CollectionService") +local Players = game:GetService("Players") +local player = Players.LocalPlayer +local TOTAL = ${TOTAL} +local won = false -local ev = getEvent("StarCollected") -ev.Event:Connect(function() - collected = collected + 1 - print("Собрано: " .. collected .. "/" .. total) - if collected >= total then - print("ПОБЕДА! Все звёзды собраны!") +__rbxl_show_text("Собери все ЖЁЛТЫЕ звёзды!", 3) + +-- Счётчик в правом верхнем углу +local screenGui = Instance.new("ScreenGui", player.PlayerGui) +local label = Instance.new("TextLabel", screenGui) +label.Size = UDim2.new(0, 220, 0, 50) +label.Position = UDim2.new(1, -240, 0, 20) +label.BackgroundColor3 = Color3.fromRGB(0, 0, 0) +label.BackgroundTransparency = 0.4 +label.TextColor3 = Color3.fromRGB(255, 215, 0) +label.TextScaled = true +label.Font = Enum.Font.SourceSansBold +label.Text = "Звёзды: 0 / " .. TOTAL + +local coinSound = Instance.new("Sound", workspace) +coinSound.SoundId = "coin"; coinSound.Volume = 0.8 +local winSound = Instance.new("Sound", workspace) +winSound.SoundId = "win"; winSound.Volume = 1 + +-- Помечаем все звёзды тегом 'звезда' (с небольшой задержкой — +-- скрипты звёзд должны успеть запуститься и зарегистрировать part). +task.delay(0.2, function() + for i = 1, TOTAL do + local star = workspace:FindFirstChild("Звезда_" .. i) + if star then CollectionService:AddTag(star, "звезда") end + end +end) + +-- Звёзды сообщают о сборе. Главный скрипт считает оставшиеся через +-- CollectionService:GetTagged — паритет с JS game.scene.getTagged. +local collectEvent = getEvent("StarCollected") +collectEvent.Event:Connect(function() + if won then return end + local left = #CollectionService:GetTagged("звезда") + label.Text = "Звёзды: " .. (TOTAL - left) .. " / " .. TOTAL + coinSound:Play() + if left == 0 then + won = true + winSound:Play() + __rbxl_show_text("Победа! Все звёзды собраны!", 5) + local px = __rbxl_player_x() + local py = __rbxl_player_y() + local pz = __rbxl_player_z() + __rbxl_spawn_particles("confetti", px, py + 3, pz, 3, 3) end end)`, - g14_star: `-- === Скрипт звезды (Lua) === + }; + // Скрипт каждой звезды — одинаковый: на touch → untag + destroy + Fire + const starScript = `-- === Скрипт звезды (Lua) === local CollectionService = game:GetService("CollectionService") local ReplicatedStorage = game:GetService("ReplicatedStorage") local part = script.Parent -CollectionService:AddTag(part, "звезда") +local picked = false part.Touched:Connect(function(hit) + if picked then return end local h = hit.Parent and hit.Parent:FindFirstChild("Humanoid") if not h then return end + picked = true + -- Снимаем тег и удаляем звезду, потом шлём событие. + CollectionService:RemoveTag(part, "звезда") + part:Destroy() local ev = ReplicatedStorage:FindFirstChild("StarCollected") if ev then ev:Fire() end - part:Destroy() -end)`, - }, +end)`; + for (let i = 1; i <= TOTAL; i++) { + overrides['g14_star_' + i] = starScript; + } + return overrides; + })(), // ═══════════════════════════════════════════════════════════════ // ИГРА 15 — «Тир»