feat(g29): полный паритет «Магазин»
JS:
- 7 монеток onTouch → broadcast coin → score++, coin sound
- прилавок onInteract E (4) → broadcast buy → coins>=5? покупка ключа
+ inventory.add('Ключ') + 'Куплен!' + win sound; иначе lose+'Мало!'
- дверь onInteract E (4) → broadcast open-door → hasKey? tween y+6;
иначе 'Дверь заперта'
- финиш → broadcast win → 'Победа!' + confetti
Lua (паритет):
- BindableEvents CoinCollected/BuyKey/OpenDoor/WinReached
- __rbxl_score_set, __rbxl_show_text, __rbxl_inventory_define/add
- 7 g29_coin_N: Touched → CoinCollected:Fire + Destroy
- g29_shop, g29_door: Heartbeat distance-check (4) + __rbxl_hud_set
'[E] Купить ключ (5 монет)' / '[E] Открыть дверь' + InputBegan E
- g29_main обрабатывает все события, при покупке: TweenService двери
Position.Y+6 + CanCollide=false
- g29_finish: Touched → WinReached:Fire (fired-флаг)
This commit is contained in:
parent
ed23ec782c
commit
facd6aa837
@ -2415,42 +2415,187 @@ end)`;
|
|||||||
// ═══════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════
|
||||||
// ИГРА 29 — «Магазин»
|
// ИГРА 29 — «Магазин»
|
||||||
// ═══════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════
|
||||||
'shop': {
|
'shop': (function() {
|
||||||
g29_main: `-- === ИГРА «МАГАЗИН» (Lua) ===
|
const COIN_IDS = [1, 2, 3, 4, 5, 6, 7];
|
||||||
local Players = game:GetService("Players")
|
const overrides = {
|
||||||
Players.PlayerAdded:Connect(function(player)
|
g29_main: `-- === ИГРА «МАГАЗИН» — главный скрипт (Lua) ===
|
||||||
local stats = Instance.new("Folder", player); stats.Name = "leaderstats"
|
${SNIPPET_BROADCAST}
|
||||||
local coins = Instance.new("IntValue", stats); coins.Name = "Монеты"; coins.Value = 20
|
|
||||||
end)
|
local TweenService = game:GetService("TweenService")
|
||||||
for _, p in ipairs(Players:GetPlayers()) do
|
local PRICE = 5
|
||||||
if not p:FindFirstChild("leaderstats") then
|
local coins = 0
|
||||||
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
|
|
||||||
local bought = false
|
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)
|
part.Touched:Connect(function(hit)
|
||||||
if bought then return end
|
if fired then return end
|
||||||
local player = Players:GetPlayerFromCharacter(hit.Parent)
|
local h = hit.Parent and hit.Parent:FindFirstChild("Humanoid")
|
||||||
if not player then return end
|
if not h then return end
|
||||||
local stats = player:FindFirstChild("leaderstats")
|
fired = true
|
||||||
if not stats then return end
|
local ev = ReplicatedStorage:FindFirstChild("WinReached")
|
||||||
if stats['Монеты'].Value >= price then
|
if ev then ev:Fire() end
|
||||||
stats['Монеты'].Value = stats['Монеты'].Value - price
|
|
||||||
bought = true
|
|
||||||
print("Куплено! Цена: " .. price)
|
|
||||||
part.Transparency = 0.7
|
|
||||||
else
|
|
||||||
print("Не хватает! Нужно " .. price .. " монет")
|
|
||||||
end
|
|
||||||
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 — «Квесты»
|
// ИГРА 30 — «Квесты»
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user