From 59769932e5e63a850cb76c6797bb5f44f23f5baa Mon Sep 17 00:00:00 2001 From: min Date: Tue, 9 Jun 2026 21:29:32 +0300 Subject: [PATCH] =?UTF-8?q?feat(g22):=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=C2=AB?= =?UTF-8?q?=D0=97=D0=BE=D0=BD=D0=B0=20=D0=BE=D0=BF=D0=B0=D1=81=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D0=B8=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JS: - showText 'Пробеги через красную зону к финишу!' - every(0.6): если inZone — damage(12) + hit - onMessage 'zone-enter' → inZone=true + 'Опасно! Беги быстрее!' - onMessage 'zone-leave' → inZone=false - onMessage 'win' → 'Победа!' + win + confetti - g22_zone: onTouch → 'zone-enter', onUntouch → 'zone-leave' - g22_heal: onTouch → heal(60) + '+60 HP' + pickup + delete - g22_finish: onTouch → 'win' Lua (паритет): - __rbxl_show_text + Sounds - BindableEvents ZoneEnter/ZoneLeave/WinReached - Heartbeat-таймер 0.6с для урона пока inZone - g22_zone: Touched/TouchEnded → ev:Fire - g22_heal: Touched → __rbxl_heal_player(60) + pickup Sound + Destroy - g22_finish: Touched → WinReached:Fire Shim добавил __rbxl_heal_player(amount) → cmd 'player.heal'. --- src/community/docsGamesBuildersLua.js | 104 ++++++++++++++++++++++---- src/editor/engine/lua/RobloxShim.js | 4 + 2 files changed, 94 insertions(+), 14 deletions(-) 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) => {