From 1345f51436cf63bc6f595d5c0e048a40075880a6 Mon Sep 17 00:00:00 2001 From: min Date: Tue, 9 Jun 2026 20:13:52 +0300 Subject: [PATCH] =?UTF-8?q?feat(g17):=20=D0=BF=D0=BE=D0=BB=D0=BD=D1=8B?= =?UTF-8?q?=D0=B9=20=D0=BF=D0=B0=D1=80=D0=B8=D1=82=D0=B5=D1=82=20=D1=81=20?= =?UTF-8?q?JS=20=C2=AB=D0=9A=D0=BB=D1=8E=D1=87=20=D0=B8=20=D1=81=D1=83?= =?UTF-8?q?=D0=BD=D0=B4=D1=83=D0=BA=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JS: - showText 'Найди ключ и открой сундук!' - onMessage 'takeKey' → inventory.add('Ключ') + 'Ты нашёл Ключ!' + pickup - onMessage 'openChest' → если has('Ключ'): 'Победа!' + win + confetti иначе: 'Сундук заперт. Сначала найди ключ.' - key: onTouch → broadcast 'takeKey' + delete - chest: onInteract E (distance=4) → broadcast 'openChest' Lua (паритет, юзер указал на отсутствие надписей/инвентаря/звуков): - __rbxl_show_text для всех подсказок (вместо print) - __rbxl_inventory_define('key','Ключ') → итем в hotbar инвентаря - __rbxl_inventory_add('key',1) при подборе (вместо leaderstats BoolValue) - __rbxl_inventory_has('key') проверка ключа в сундуке - Sounds 'pickup'/'win'/'lose' (раньше только print) - BindableEvents TakeKey + OpenChest - g17_key: Touched → ev:Fire + Destroy (с taken-флагом) - g17_chest: убран ошибочный Touched-handler. Heartbeat distance-check как в Торговце: при near=true → __rbxl_hud_set '[E] Открыть сундук' UserInputService E → OpenChest:Fire - При победе: confetti над игроком + win Sound --- src/community/docsGamesBuildersLua.js | 109 +++++++++++++++++++------- 1 file changed, 79 insertions(+), 30 deletions(-) diff --git a/src/community/docsGamesBuildersLua.js b/src/community/docsGamesBuildersLua.js index 50a908d..e54f241 100644 --- a/src/community/docsGamesBuildersLua.js +++ b/src/community/docsGamesBuildersLua.js @@ -1468,45 +1468,94 @@ end)`, // ИГРА 17 — «Ключ от сундука» // ═══════════════════════════════════════════════════════════════ 'key-chest': { - g17_main: `-- === ИГРА «КЛЮЧ ОТ СУНДУКА» (Lua) === -local Players = game:GetService("Players") -Players.PlayerAdded:Connect(function(player) - local stats = Instance.new("Folder", player); stats.Name = "leaderstats" - local key = Instance.new("BoolValue", stats); key.Name = "Ключ" + g17_main: `-- === ИГРА «КЛЮЧ И СУНДУК» — главный скрипт (Lua) === +${SNIPPET_BROADCAST} + +local won = false + +__rbxl_show_text("Найди ключ и открой сундук!", 3) + +local pickupSound = Instance.new("Sound", workspace) +pickupSound.SoundId = "pickup"; pickupSound.Volume = 0.8 +local winSound = Instance.new("Sound", workspace) +winSound.SoundId = "win"; winSound.Volume = 1 +local loseSound = Instance.new("Sound", workspace) +loseSound.SoundId = "lose"; loseSound.Volume = 0.6 + +-- Определяем итем "Ключ" в инвентаре (показывает иконку в hotbar) +__rbxl_inventory_define("key", "Ключ", "#ffd700") + +-- Игрок подобрал ключ +local takeEvent = getEvent("TakeKey") +takeEvent.Event:Connect(function() + __rbxl_inventory_add("key", 1) + __rbxl_show_text("Ты нашёл Ключ!", 2) + pickupSound:Play() end) -for _, p in ipairs(Players:GetPlayers()) do - if not p:FindFirstChild("leaderstats") then - local stats = Instance.new("Folder", p); stats.Name = "leaderstats" - local key = Instance.new("BoolValue", stats); key.Name = "Ключ" + +-- Игрок пытается открыть сундук +local openEvent = getEvent("OpenChest") +openEvent.Event:Connect(function() + if won then return end + if not __rbxl_inventory_has("key") then + __rbxl_show_text("Сундук заперт. Сначала найди ключ.", 2) + loseSound:Play() + return end -end -print("Найди ключ и открой сундук!")`, + won = true + __rbxl_show_text("Победа! Сундук открыт — там сокровище!", 5) + winSound:Play() + 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)`, g17_key: `-- === Скрипт ключа (Lua) === -local Players = game:GetService("Players") +-- При касании игроком — отправляем событие и удаляем ключ. +local ReplicatedStorage = game:GetService("ReplicatedStorage") local part = script.Parent +local taken = false + part.Touched:Connect(function(hit) - local player = Players:GetPlayerFromCharacter(hit.Parent) - if not player then return end - local stats = player:FindFirstChild("leaderstats") - if stats and stats:FindFirstChild("Ключ") then - stats['Ключ'].Value = true - print("Подобрал ключ!") - part:Destroy() - end + if taken then return end + local h = hit.Parent and hit.Parent:FindFirstChild("Humanoid") + if not h then return end + taken = true + local ev = ReplicatedStorage:FindFirstChild("TakeKey") + if ev then ev:Fire() end + part:Destroy() end)`, g17_chest: `-- === Скрипт сундука (Lua) === -local Players = game:GetService("Players") +-- Подойти и нажать E чтобы открыть. +local UserInputService = game:GetService("UserInputService") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") local part = script.Parent -part.Touched:Connect(function(hit) - local player = Players:GetPlayerFromCharacter(hit.Parent) - if not player then return end - local stats = player:FindFirstChild("leaderstats") - if stats and stats['Ключ'] and stats['Ключ'].Value then - print("Сундук открыт! ПОБЕДА!") - part.Color = Color3.fromRGB(255, 215, 0) - else - print("Нужен ключ!") +local hintVisible = false + +RunService.Heartbeat:Connect(function() + local px = __rbxl_player_x() + local pz = __rbxl_player_z() + local dx = part.Position.X - px + local dz = part.Position.Z - pz + local dist = math.sqrt(dx*dx + dz*dz) + local near = dist <= 4 + if near ~= hintVisible then + hintVisible = near + if near then + __rbxl_hud_set("g17_chest_hint", "[E] Открыть сундук", 50, 75, "#ffe44a", 20) + else + __rbxl_hud_set("g17_chest_hint", nil) + end end +end) + +UserInputService.InputBegan:Connect(function(input, gp) + if gp then return end + if not hintVisible then return end + if input.KeyCode ~= Enum.KeyCode.E then return end + local ev = ReplicatedStorage:FindFirstChild("OpenChest") + if ev then ev:Fire() end end)`, },