diff --git a/src/community/docsGamesBuildersLua.js b/src/community/docsGamesBuildersLua.js index db17b2d..aefa765 100644 --- a/src/community/docsGamesBuildersLua.js +++ b/src/community/docsGamesBuildersLua.js @@ -1359,13 +1359,73 @@ end)`; // ИГРА 16 — «Лавовый пол» // ═══════════════════════════════════════════════════════════════ 'lava-floor': { - g16_main: `-- === ИГРА «ЛАВОВЫЙ ПОЛ» (Lua) === -print("Прыгай по островкам, не упади в лаву!")`, + g16_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 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 < -2 then + player:LoadCharacter() + 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)`, g16_lava: `-- === Скрипт лавы (Lua) === +-- Игрок коснулся лавы — урон. У damage есть защита (i-frames), +-- так что урон не каждый кадр, а раз в ~0.5 секунды. +-- ВАЖНО: лава-зона может пересекаться с островками по AABB. Проверяем +-- что игрок РЕАЛЬНО внизу (стоит в лаве), а не на островке выше. local part = script.Parent +local hitSound = Instance.new("Sound", part) +hitSound.SoundId = "hit"; hitSound.Volume = 0.7 + part.Touched:Connect(function(hit) local h = hit.Parent and hit.Parent:FindFirstChild("Humanoid") - if h then h.Health = 0 end + if not h then return end + -- Игрок на безопасной высоте (на островке/финише) — не урон. + -- Лава-зона на y=1, верх y=1.3. Островки на y=1.2 верх y=1.5. + -- Игрок СТОИТ на островке когда его _pos.y - halfH (= нижняя точка + -- капсулы) ~= верх островка. Стоит на лаве когда нижняя точка ниже 1.3. + local py = __rbxl_player_y() + if py >= 1.35 then return end -- стоит на островке/финише — пропускаем + __rbxl_damage_player(20) + hitSound:Play() +end)`, + g16_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 e56720c..984e8ae 100644 --- a/src/editor/engine/lua/RobloxShim.js +++ b/src/editor/engine/lua/RobloxShim.js @@ -1904,6 +1904,11 @@ export function registerRobloxShim(lua, opts) { else _localInventory.set(id, newCount); send('inv2.remove', { itemId: id, count: c }); }); + // Урон игроку — паритет с JS game.player.damage(amount). + // У игрока есть i-frames (~0.5с), так что урон не каждый кадр. + global.set('__rbxl_damage_player', (amount) => { + send('player.damage', { amount: Number(amount) || 0 }); + }); // Подброс игрока — паритет с JS game.player.boostJump(strength). // 1.0 = обычный прыжок, 3.0 = втрое выше, и т.д. global.set('__rbxl_boost_jump', (strength) => {