From 50b08b81bc3cb255f5607e3977279e7fafbe3670 Mon Sep 17 00:00:00 2001 From: min Date: Tue, 9 Jun 2026 18:44:34 +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=2010=20=C2=AB?= =?UTF-8?q?=D0=9F=D1=80=D1=8B=D0=B6=D0=BE=D0=BA-=D0=BF=D1=80=D1=83=D0=B6?= =?UTF-8?q?=D0=B8=D0=BD=D0=B0=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JS: - showText 'Прыгай по батутам всё выше!' - onTick: y<-3 → respawn + lose sound - onMessage 'win' → showText + win + confetti - g10_tramp_N: onTouch → player.boostJump(3.2) + jump sound - g10_finish: onTouch → broadcast 'win' Lua (паритет): - __rbxl_show_text подсказка + 'Победа!' - Heartbeat: __rbxl_player_y() < -3 → LoadCharacter + lose Sound - BindableEvent WinReached + g10_finish.Touched → ev:Fire - При win — confetti Добавил хелпер в shim: - __rbxl_boost_jump(strength) → send 'player.boostJump' 3.2 = втрое выше обычного прыжка g10_tramp_4/5/6: Touched → __rbxl_boost_jump(3.2) + jump Sound с защитой от зацикливания (минимум 0.5с между активациями). --- src/community/docsGamesBuildersLua.js | 85 +++++++++++++++++++++++---- src/editor/engine/lua/RobloxShim.js | 5 ++ 2 files changed, 79 insertions(+), 11 deletions(-) diff --git a/src/community/docsGamesBuildersLua.js b/src/community/docsGamesBuildersLua.js index 437e3ac..3856f82 100644 --- a/src/community/docsGamesBuildersLua.js +++ b/src/community/docsGamesBuildersLua.js @@ -721,20 +721,83 @@ end)`, // ═══════════════════════════════════════════════════════════════ // ИГРА 10 — «Прыжки на пружинах» // ═══════════════════════════════════════════════════════════════ - 'spring-jump': { - g10_main: `-- === ИГРА «ПРЫЖКИ НА ПРУЖИНАХ» — главный скрипт (Lua) === -print("Прыгай с пружины на пружину до финиша!")`, - g10_spring: `-- === Скрипт пружины (Lua) === + 'spring-jump': (function() { + const overrides = { + g10_main: `-- === ИГРА «ПРЫЖОК-ПРУЖИНА» — главный скрипт (Lua) === +${SNIPPET_BROADCAST} + +local Players = game:GetService("Players") +local RunService = game:GetService("RunService") +local player = Players.LocalPlayer +local won = false + +__rbxl_show_text("Прыгай по батутам всё выше!", 3) + +local loseSound = Instance.new("Sound", workspace) +loseSound.SoundId = "lose"; loseSound.Volume = 1 +local winSound = Instance.new("Sound", workspace) +winSound.SoundId = "win"; winSound.Volume = 1 + +-- Каждый кадр проверяем: упал вниз — на старт +RunService.Heartbeat:Connect(function() + if won then return end + local py = __rbxl_player_y() + if py < -3 then + player:LoadCharacter() + loseSound:Play() + end +end) + +-- Финиш-зона шлёт BindableEvent +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)`, + g10_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)`, + }; + // Скрипт каждого батута — одинаковый код + const trampScript = `-- === Скрипт батута (Lua) === +-- Игрок встал на батут — мощный подброс вверх. +local part = script.Parent +local jumpSound = Instance.new("Sound", part) +jumpSound.SoundId = "jump"; jumpSound.Volume = 0.7 + +local lastBoost = 0 part.Touched:Connect(function(hit) local h = hit.Parent and hit.Parent:FindFirstChild("Humanoid") - local hrp = hit.Parent and hit.Parent:FindFirstChild("HumanoidRootPart") - if h and hrp then - -- Подбрасываем игрока вверх - hrp.Velocity = Vector3.new(hrp.Velocity.X, 80, hrp.Velocity.Z) - end -end)`, - }, + if not h then return end + -- Не зацикливаем подброс — минимум 0.5с между активациями + local now = tick() + if now - lastBoost < 0.5 then return end + lastBoost = now + __rbxl_boost_jump(3.2) -- 3.2 = втрое выше обычного прыжка + jumpSound:Play() +end)`; + // Батуты в JS-builder имеют id 4, 5, 6 (после трёх этажей) + for (const tid of [4, 5, 6]) { + overrides['g10_tramp_' + tid] = trampScript; + } + return overrides; + })(), // ═══════════════════════════════════════════════════════════════ // ИГРА 11 — «Эхо» (нажми кнопку → звук) diff --git a/src/editor/engine/lua/RobloxShim.js b/src/editor/engine/lua/RobloxShim.js index 206dc56..e85c597 100644 --- a/src/editor/engine/lua/RobloxShim.js +++ b/src/editor/engine/lua/RobloxShim.js @@ -1816,6 +1816,11 @@ export function registerRobloxShim(lua, opts) { color: color || '#ffffff', }); }); + // Подброс игрока — паритет с JS game.player.boostJump(strength). + // 1.0 = обычный прыжок, 3.0 = втрое выше, и т.д. + global.set('__rbxl_boost_jump', (strength) => { + send('player.boostJump', { strength: Number(strength) || 1 }); + }); // Эффекты частиц (confetti, sparks и т.п.) — как game.scene.spawnParticles. // BabylonScene._spawnParticleEffect ждёт payload.type и payload.position. global.set('__rbxl_spawn_particles', (kind, x, y, z, duration, count) => {