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) => {