From 73bf9f5c340cb3c18a8b522d61280ea00878fb20 Mon Sep 17 00:00:00 2001 From: min Date: Tue, 9 Jun 2026 18:16:43 +0300 Subject: [PATCH] =?UTF-8?q?feat(lua-games):=20=D0=BF=D0=BE=D0=BB=D0=BD?= =?UTF-8?q?=D1=8B=D0=B9=20=D0=BF=D0=B0=D1=80=D0=B8=D1=82=D0=B5=D1=82=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=B8=D0=B3=D1=80=D1=8B=208=20=C2=AB?= =?UTF-8?q?=D0=91=D0=B5=D0=B3=D0=B8=20=D0=BA=20=D1=84=D0=B8=D0=BD=D0=B8?= =?UTF-8?q?=D1=88=D1=83=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JS: - ui.timer + showText 'Беги к зелёному финишу — на время!' - onTick: time += dt - onMessage 'finish' → 'Финиш! Время: N сек' + win + confetti - g8_finish: onTouch → broadcast 'finish' Lua (паритет): - ScreenGui+TextLabel секундомер вверху по центру '0.0 сек' - __rbxl_show_text подсказка - RunService.Heartbeat: time += dt → label.Text каждый кадр - BindableEvent FinishReached - g8_finish: Touched → ev:Fire с fired-флагом - При финише: 'Финиш! Твоё время: X.X сек' + win Sound + confetti --- src/community/docsGamesBuildersLua.js | 64 +++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/src/community/docsGamesBuildersLua.js b/src/community/docsGamesBuildersLua.js index 2166f9f..646c9a7 100644 --- a/src/community/docsGamesBuildersLua.js +++ b/src/community/docsGamesBuildersLua.js @@ -564,18 +564,66 @@ end)`, // ИГРА 8 — «Беги до финиша» // ═══════════════════════════════════════════════════════════════ 'run-to-finish': { - g8_main: `-- === ИГРА «БЕГИ ДО ФИНИША» — главный скрипт (Lua) === -print("Беги к зелёной плите!")`, - g8_finish: `-- === Финишная плита (Lua) === + g8_main: `-- === ИГРА «БЕГИ К ФИНИШУ» — главный скрипт (Lua) === +${SNIPPET_BROADCAST} + +local Players = game:GetService("Players") +local RunService = game:GetService("RunService") +local player = Players.LocalPlayer +local finished = false +local time = 0 + +__rbxl_show_text("Беги к зелёному финишу — на время!", 3) + +-- Секундомер вверху по центру +local screenGui = Instance.new("ScreenGui", player.PlayerGui) +local timerLabel = Instance.new("TextLabel", screenGui) +timerLabel.Size = UDim2.new(0, 220, 0, 60) +timerLabel.Position = UDim2.new(0.5, -110, 0, 20) +timerLabel.BackgroundColor3 = Color3.fromRGB(0, 0, 0) +timerLabel.BackgroundTransparency = 0.4 +timerLabel.TextColor3 = Color3.fromRGB(255, 255, 255) +timerLabel.TextScaled = true +timerLabel.Font = Enum.Font.SourceSansBold +timerLabel.Text = "0.0 сек" + +local winSound = Instance.new("Sound", workspace) +winSound.SoundId = "win"; winSound.Volume = 1 + +-- Каждый кадр прибавляем dt к таймеру +RunService.Heartbeat:Connect(function(dt) + if finished then return end + time = time + (dt or 0.016) + -- Округляем до одного знака для отображения + local rounded = math.floor(time * 10) / 10 + timerLabel.Text = string.format("%.1f сек", rounded) +end) + +-- Финиш-зона шлёт BindableEvent +local finishEvent = getEvent("FinishReached") +finishEvent.Event:Connect(function() + if finished then return end + finished = true + local t = math.floor(time * 10) / 10 + winSound:Play() + __rbxl_show_text("Финиш! Твоё время: " .. string.format("%.1f", t) .. " сек", 6) + 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)`, + g8_finish: `-- === Скрипт финиша (Lua) === +local ReplicatedStorage = game:GetService("ReplicatedStorage") local part = script.Parent -local won = false +local fired = false + part.Touched:Connect(function(hit) - if won then return end + if fired then return end local h = hit.Parent and hit.Parent:FindFirstChild("Humanoid") if not h then return end - won = true - print("ПОБЕДА! Ты добежал!") - h.WalkSpeed = 0 + fired = true + local ev = ReplicatedStorage:FindFirstChild("FinishReached") + if ev then ev:Fire() end end)`, },