diff --git a/src/community/docsGamesBuildersLua.js b/src/community/docsGamesBuildersLua.js index b2e26fc..765cdd3 100644 --- a/src/community/docsGamesBuildersLua.js +++ b/src/community/docsGamesBuildersLua.js @@ -1860,28 +1860,104 @@ end)`, // ИГРА 22 — «Опасная зона» // ═══════════════════════════════════════════════════════════════ 'danger-zone': { - g22_main: `-- === ИГРА «ОПАСНАЯ ЗОНА» (Lua) === -print("Не стой в красной зоне!")`, - g22_zone: `-- === Скрипт опасной зоны (Lua) === + g22_main: `-- === ИГРА «ЗОНА ОПАСНОСТИ» — главный скрипт (Lua) === +${SNIPPET_BROADCAST} + +local RunService = game:GetService("RunService") +local inZone = false +local won = false +local damageTimer = 0 + +__rbxl_show_text("Пробеги через красную зону к финишу!", 3) + +local hitSound = Instance.new("Sound", workspace) +hitSound.SoundId = "hit"; hitSound.Volume = 0.6 +local winSound = Instance.new("Sound", workspace) +winSound.SoundId = "win"; winSound.Volume = 1 + +-- Слушатели событий зоны +local enterEvent = getEvent("ZoneEnter") +enterEvent.Event:Connect(function() + inZone = true + __rbxl_show_text("Опасно! Беги быстрее!", 1.5) +end) +local leaveEvent = getEvent("ZoneLeave") +leaveEvent.Event:Connect(function() + inZone = false +end) + +-- Урон каждые 0.6с пока игрок в зоне +RunService.Heartbeat:Connect(function(dt) + if won then return end + if not inZone then return end + damageTimer = damageTimer + (dt or 0.016) + if damageTimer >= 0.6 then + damageTimer = 0 + __rbxl_damage_player(12) + hitSound:Play() + end +end) + +-- Финиш сообщает о победе +local winEvent = getEvent("WinReached") +winEvent.Event:Connect(function() + if won then return end + won = true + winSound:Play() + __rbxl_show_text("Победа! Ты прошёл зону опасности!", 5) + 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)`, + g22_zone: `-- === Скрипт зоны опасности (Lua) === +-- Touched при входе, TouchEnded при выходе. +local ReplicatedStorage = game:GetService("ReplicatedStorage") local part = script.Parent -local insiders = {} part.Touched:Connect(function(hit) local h = hit.Parent and hit.Parent:FindFirstChild("Humanoid") - if h then insiders[h] = true end + if not h then return end + local ev = ReplicatedStorage:FindFirstChild("ZoneEnter") + if ev then ev:Fire() end end) part.TouchEnded:Connect(function(hit) local h = hit.Parent and hit.Parent:FindFirstChild("Humanoid") - if h then insiders[h] = nil end -end) + if not h then return end + local ev = ReplicatedStorage:FindFirstChild("ZoneLeave") + if ev then ev:Fire() end +end)`, + g22_heal: `-- === Скрипт аптечки (Lua) === +local part = script.Parent +local taken = false --- Урон каждые 0.5 сек пока стоят -while true do - task.wait(0.5) - for h in pairs(insiders) do - if h.Parent then h:TakeDamage(5) end - end -end`, +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 + -- Лечим на 60 HP (через damage с отрицательным значением неудобно; + -- используем напрямую player.Health прибавлением). + __rbxl_heal_player(60) + __rbxl_show_text("+60 HP", 1.5) + local pickupSound = Instance.new("Sound", part) + pickupSound.SoundId = "pickup"; pickupSound.Volume = 0.8 + pickupSound:Play() + part:Destroy() +end)`, + g22_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)`, }, // ═══════════════════════════════════════════════════════════════ diff --git a/src/editor/engine/lua/RobloxShim.js b/src/editor/engine/lua/RobloxShim.js index 369c713..ffc1dfd 100644 --- a/src/editor/engine/lua/RobloxShim.js +++ b/src/editor/engine/lua/RobloxShim.js @@ -1961,6 +1961,10 @@ export function registerRobloxShim(lua, opts) { global.set('__rbxl_damage_player', (amount) => { send('player.damage', { amount: Number(amount) || 0 }); }); + // Лечение игрока — паритет с JS game.player.heal(amount). + global.set('__rbxl_heal_player', (amount) => { + send('player.heal', { amount: Number(amount) || 0 }); + }); // Подброс игрока — паритет с JS game.player.boostJump(strength). // 1.0 = обычный прыжок, 3.0 = втрое выше, и т.д. global.set('__rbxl_boost_jump', (strength) => {