diff --git a/src/community/docsGamesBuildersLua.js b/src/community/docsGamesBuildersLua.js index 278f5cb..bfce9b1 100644 --- a/src/community/docsGamesBuildersLua.js +++ b/src/community/docsGamesBuildersLua.js @@ -2290,39 +2290,58 @@ end)`; // ИГРА 27 — «Двойной прыжок» // ═══════════════════════════════════════════════════════════════ 'double-jump': { - g27_main: `-- === ИГРА «ДВОЙНОЙ ПРЫЖОК» (Lua) === + g27_main: `-- === ИГРА «ДВОЙНОЙ ПРЫЖОК» — главный скрипт (Lua) === +${SNIPPET_BROADCAST} + local Players = game:GetService("Players") -local UserInputService = game:GetService("UserInputService") +local RunService = game:GetService("RunService") +local player = Players.LocalPlayer +local won = false -local function setupDoubleJump(player) - local jumpsLeft = 2 - local char = player.Character or player.CharacterAdded:Wait() - local h = char:WaitForChild("Humanoid") +-- Включаем игроку двойной прыжок — теперь можно прыгнуть ещё раз в воздухе +__rbxl_set_double_jump(true) +__rbxl_show_text("Жми Space ДВАЖДЫ — двойной прыжок!", 4) - -- Восстанавливаем прыжки при касании земли - h.StateChanged:Connect(function(_, newState) - if newState == Enum.HumanoidStateType.Landed then - jumpsLeft = 2 - end - end) +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 - UserInputService.InputBegan:Connect(function(input, gp) - if gp then return end - if input.KeyCode == Enum.KeyCode.Space and jumpsLeft > 0 then - jumpsLeft = jumpsLeft - 1 - if jumpsLeft == 1 then - local hrp = char:FindFirstChild("HumanoidRootPart") - if hrp then - hrp.Velocity = Vector3.new(hrp.Velocity.X, 50, hrp.Velocity.Z) - end - end - end - end) -end +-- Респаун при падении в пропасть +RunService.Heartbeat:Connect(function() + if won then return end + local py = __rbxl_player_y() + if py < -3 then + player:LoadCharacter() + loseSound:Play() + end +end) -Players.PlayerAdded:Connect(setupDoubleJump) -for _, p in ipairs(Players:GetPlayers()) do setupDoubleJump(p) end -print("Жми Space дважды — двойной прыжок!")`, +-- Финиш сообщает о победе +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)`, + g27_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 20f8b2f..7f9a77f 100644 --- a/src/editor/engine/lua/RobloxShim.js +++ b/src/editor/engine/lua/RobloxShim.js @@ -1970,6 +1970,10 @@ export function registerRobloxShim(lua, opts) { const text = value == null ? null : ('Очки: ' + value); send('ui.set', { id: '__score', text }); }); + // Двойной прыжок — паритет с JS game.player.setDoubleJump(bool). + global.set('__rbxl_set_double_jump', (enabled) => { + send('player.setDoubleJump', { enabled: !!enabled }); + }); // Камера-облёт — паритет с JS game.camera.cutscene(points, opts). // pointsFlat/lookAtFlat: x1,y1,z1,x2,y2,z2,... — потому что массив // объектов в wasmoon через C-boundary неудобен.