diff --git a/src/community/docsGamesBuildersLua.js b/src/community/docsGamesBuildersLua.js index 38d91d2..f115b63 100644 --- a/src/community/docsGamesBuildersLua.js +++ b/src/community/docsGamesBuildersLua.js @@ -2415,42 +2415,187 @@ end)`; // ═══════════════════════════════════════════════════════════════ // ИГРА 29 — «Магазин» // ═══════════════════════════════════════════════════════════════ - 'shop': { - g29_main: `-- === ИГРА «МАГАЗИН» (Lua) === -local Players = game:GetService("Players") -Players.PlayerAdded:Connect(function(player) - local stats = Instance.new("Folder", player); stats.Name = "leaderstats" - local coins = Instance.new("IntValue", stats); coins.Name = "Монеты"; coins.Value = 20 -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 = 20 - end -end -print("У тебя 20 монет — купи что-нибудь!")`, - g29_item: `-- === Скрипт товара (Lua) === -local Players = game:GetService("Players") -local part = script.Parent -local price = part:GetAttribute("Price") or 5 + 'shop': (function() { + const COIN_IDS = [1, 2, 3, 4, 5, 6, 7]; + const overrides = { + g29_main: `-- === ИГРА «МАГАЗИН» — главный скрипт (Lua) === +${SNIPPET_BROADCAST} + +local TweenService = game:GetService("TweenService") +local PRICE = 5 +local coins = 0 local bought = false +local hasKey = false +local doorOpen = false +local won = false + +__rbxl_score_set(0) +__rbxl_show_text("Собери монетки и купи ключ у продавца!", 4) + +local coinSound = Instance.new("Sound", workspace) +coinSound.SoundId = "coin"; coinSound.Volume = 0.7 +local loseSound = Instance.new("Sound", workspace) +loseSound.SoundId = "lose"; loseSound.Volume = 0.7 +local winSound = Instance.new("Sound", workspace) +winSound.SoundId = "win"; winSound.Volume = 1 + +-- Сбор монетки +local coinEvent = getEvent("CoinCollected") +coinEvent.Event:Connect(function() + coins = coins + 1 + __rbxl_score_set(coins) + coinSound:Play() +end) + +-- Покупка ключа у прилавка +local buyEvent = getEvent("BuyKey") +buyEvent.Event:Connect(function() + if bought then + __rbxl_show_text("Ключ уже куплен, иди к двери!", 2) + return + end + if coins < PRICE then + __rbxl_show_text("Мало монет! Нужно " .. PRICE .. ", есть " .. coins, 2) + loseSound:Play() + return + end + bought = true + hasKey = true + coins = coins - PRICE + __rbxl_score_set(coins) + __rbxl_inventory_define("key", "Ключ", "#ffd700") + __rbxl_inventory_add("key", 1) + __rbxl_show_text("Куплен Ключ! Открой дверь.", 3) + winSound:Play() +end) + +-- Открытие двери +local doorEvent = getEvent("OpenDoor") +doorEvent.Event:Connect(function() + if doorOpen then return end + if not hasKey then + __rbxl_show_text("Дверь заперта. Купи ключ в магазине.", 2) + return + end + doorOpen = true + 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 + __rbxl_show_text("Дверь открыта!", 2) +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)`, + g29_shop: `-- === Скрипт прилавка (Lua) === +local UserInputService = game:GetService("UserInputService") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local part = script.Parent +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("g29_shop_hint", "[E] Купить ключ (5 монет)", 50, 75, "#ffe44a", 20) + else + __rbxl_hud_set("g29_shop_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("BuyKey") + if ev then ev:Fire() end +end)`, + g29_door: `-- === Скрипт двери (Lua) === +local UserInputService = game:GetService("UserInputService") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local part = script.Parent +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("g29_door_hint", "[E] Открыть дверь", 50, 75, "#ffe44a", 20) + else + __rbxl_hud_set("g29_door_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("OpenDoor") + if ev then ev:Fire() end +end)`, + g29_finish: `-- === Скрипт финиш-зоны (Lua) === +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local part = script.Parent +local fired = false part.Touched:Connect(function(hit) - if bought then return end - 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 >= price then - stats['Монеты'].Value = stats['Монеты'].Value - price - bought = true - print("Куплено! Цена: " .. price) - part.Transparency = 0.7 - else - print("Не хватает! Нужно " .. price .. " монет") - end + 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)`, - }, + }; + // 7 монеток — Touched → CoinCollected:Fire + Destroy + const coinScript = `-- === Скрипт монетки (Lua) === +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local part = script.Parent +local taken = false + +part.Touched:Connect(function(hit) + 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("CoinCollected") + if ev then ev:Fire() end + part:Destroy() +end)`; + for (const cid of COIN_IDS) { + overrides['g29_coin_' + cid] = coinScript; + } + return overrides; + })(), // ═══════════════════════════════════════════════════════════════ // ИГРА 30 — «Квесты»