From e163fe97702c8b832f0e9c9fc4fec2879d6040ad Mon Sep 17 00:00:00 2001 From: min Date: Tue, 9 Jun 2026 18:56:28 +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=2013=20=C2=AB?= =?UTF-8?q?=D0=A2=D0=BE=D1=80=D0=B3=D0=BE=D0=B2=D0=B5=D1=86=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JS: - spawnNpc торговец, prompts E: Прилавок onInteract → broadcast 'talk' → выдать ключ через inventory Дверь onInteract → broadcast 'openDoor' → проверка inventory.has → tween двери (y:9) - Финиш onTouch → broadcast 'win' → confetti Lua (паритет, NPC через статичный прилавок): - ScreenGui 'Ключа нет' / 'У тебя есть Ключ' (вместо inventory) - BindableEvents TalkTrader / OpenDoor / WinReached - g13_counter: BillboardGui '[E] Поговорить с торговцем' в радиусе 4 + UserInputService E → TalkTrader:Fire - g13_door: BillboardGui '[E] Открыть дверь' в радиусе 4 + E → OpenDoor:Fire (или 'Дверь заперта' если ключа нет) - g13_main: TalkTrader → если ключа нет: hasKey=true + 'Привет!' + pickup Sound OpenDoor → если hasKey: tween двери +6 по Y + win Sound WinReached → 'Победа!' + confetti - g13_finish: Touched → WinReached:Fire (fired-флаг) --- src/community/docsGamesBuildersLua.js | 190 ++++++++++++++++++++++---- 1 file changed, 163 insertions(+), 27 deletions(-) diff --git a/src/community/docsGamesBuildersLua.js b/src/community/docsGamesBuildersLua.js index e8202e2..602d11b 100644 --- a/src/community/docsGamesBuildersLua.js +++ b/src/community/docsGamesBuildersLua.js @@ -1043,36 +1043,172 @@ end)`; // ИГРА 13 — «Торговец» // ═══════════════════════════════════════════════════════════════ 'trader': { - g13_main: `-- === ИГРА «ТОРГОВЕЦ» (Lua) === -local Players = game:GetService("Players") + g13_main: `-- === ИГРА «ТОРГОВЕЦ» — главный скрипт (Lua) === +${SNIPPET_BROADCAST} -Players.PlayerAdded:Connect(function(player) - local stats = Instance.new("Folder", player); stats.Name = "leaderstats" - local coins = Instance.new("IntValue", stats); coins.Name = "Монеты"; coins.Value = 10 -end) -for _, p in ipairs(Players:GetPlayers()) do - if not p:FindFirstChild("leaderstats") then - local stats = Instance.new("Folder", p); stats.Name = "leaderstats" - local coins = Instance.new("IntValue", stats); coins.Name = "Монеты"; coins.Value = 10 - end -end -print("У тебя 10 монет. Купи зелье у торговца!")`, - g13_npc: `-- === Скрипт торговца (Lua) === local Players = game:GetService("Players") -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 not stats then return end - if stats['Монеты'].Value >= 5 then - stats['Монеты'].Value = stats['Монеты'].Value - 5 - local h = hit.Parent:FindFirstChild("Humanoid") - if h then h.Health = math.min(h.MaxHealth, h.Health + 50) end - print("Купил зелье! +50 HP. Осталось монет: " .. stats['Монеты'].Value) - else - print("Не хватает монет! Нужно 5") +local TweenService = game:GetService("TweenService") +local player = Players.LocalPlayer +local hasKey = false +local won = false + +__rbxl_show_text("Поговори с торговцем — нажми E у прилавка", 4) + +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 + +-- Простой "инвентарь" в HUD: ключ +local screenGui = Instance.new("ScreenGui", player.PlayerGui) +local invLabel = Instance.new("TextLabel", screenGui) +invLabel.Size = UDim2.new(0, 220, 0, 40) +invLabel.Position = UDim2.new(1, -240, 0, 20) +invLabel.BackgroundColor3 = Color3.fromRGB(0, 0, 0) +invLabel.BackgroundTransparency = 0.4 +invLabel.TextColor3 = Color3.fromRGB(255, 215, 0) +invLabel.TextScaled = true +invLabel.Font = Enum.Font.SourceSansBold +invLabel.Text = "Ключа нет" + +-- Игрок заговорил с торговцем +local talkEvent = getEvent("TalkTrader") +talkEvent.Event:Connect(function() + if hasKey then + __rbxl_show_text("Торговец: Иди к двери, ключ у тебя!", 3) + return end + hasKey = true + invLabel.Text = "У тебя есть Ключ" + invLabel.TextColor3 = Color3.fromRGB(100, 255, 100) + __rbxl_show_text("Торговец: Привет! Вот тебе ключ от двери. Удачи!", 4) + pickupSound:Play() +end) + +-- Игрок пытается открыть дверь +local openEvent = getEvent("OpenDoor") +openEvent.Event:Connect(function() + if not hasKey then + __rbxl_show_text("Дверь заперта. Нужен ключ от торговца.", 2) + return + end + __rbxl_show_text("Ключ подошёл! Дверь открыта.", 3) + winSound:Play() + local door = workspace:FindFirstChild("Дверь") + if door then + local dp = door.Position + local goal = { Position = Vector3.new(dp.X, dp.Y + 6, dp.Z) } + TweenService:Create(door, TweenInfo.new(1.2), goal):Play() + door.CanCollide = false + end +end) + +-- Игрок встал на финиш +local winEvent = getEvent("WinReached") +winEvent.Event:Connect(function() + if won then return end + 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)`, + g13_counter: `-- === Скрипт прилавка (Lua) === +-- Подойди и нажми E чтобы поговорить с торговцем. +local UserInputService = game:GetService("UserInputService") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local part = script.Parent +local hintVisible = false + +local hintGui = Instance.new("BillboardGui", part) +hintGui.Size = UDim2.new(5, 0, 1, 0) +hintGui.StudsOffset = Vector3.new(0, 2.5, 0) +hintGui.AlwaysOnTop = true +local label = Instance.new("TextLabel", hintGui) +label.Size = UDim2.new(1, 0, 1, 0) +label.BackgroundTransparency = 1 +label.TextColor3 = Color3.fromRGB(255, 255, 255) +label.TextStrokeTransparency = 0 +label.TextScaled = true +label.Text = "[E] Поговорить с торговцем" +label.Visible = 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 + label.Visible = near + 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("TalkTrader") + if ev then ev:Fire() end +end)`, + g13_door: `-- === Скрипт двери (Lua) === +-- Подойди и нажми E чтобы открыть дверь (нужен ключ). +local UserInputService = game:GetService("UserInputService") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local part = script.Parent +local hintVisible = false + +local hintGui = Instance.new("BillboardGui", part) +hintGui.Size = UDim2.new(4, 0, 1, 0) +hintGui.StudsOffset = Vector3.new(0, 3.5, 0) +hintGui.AlwaysOnTop = true +local label = Instance.new("TextLabel", hintGui) +label.Size = UDim2.new(1, 0, 1, 0) +label.BackgroundTransparency = 1 +label.TextColor3 = Color3.fromRGB(255, 255, 255) +label.TextStrokeTransparency = 0 +label.TextScaled = true +label.Text = "[E] Открыть дверь" +label.Visible = 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 + label.Visible = near + 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("OpenDoor") + if ev then ev:Fire() end +end)`, + g13_finish: `-- === Скрипт финиша (Lua) === +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local part = script.Parent +local fired = false + +part.Touched:Connect(function(hit) + if fired then return end + local h = hit.Parent and hit.Parent:FindFirstChild("Humanoid") + if not h then return end + fired = true + local ev = ReplicatedStorage:FindFirstChild("WinReached") + if ev then ev:Fire() end end)`, },