feat(lua-games): полный паритет для игры 2 «Прыгай по платформам»

JS-версия имела:
- ui.showText('Допрыгай до зелёной площадки!', 3)
- onTick: y<-3 → respawn + 'Упал!' + sound 'lose'
- broadcast 'finish' → 'Победа!' + sound 'win' + конфетти
- finish-зона: onTouch → broadcast 'finish'

Lua-версия (паритет):
- ScreenGui подсказка 'Допрыгай до зелёной площадки!' на 3с
- RunService.Heartbeat: hrp.Y < -3 → player:LoadCharacter() + Sound
  'lose' + красный TextLabel 'Упал! Пробуй снова.' на 1.5с
- BindableEvent FinishReached в ReplicatedStorage
- g2_finish: Touched на финиш-зоне → ev:Fire (только 1 раз через fired-флаг)
- g2_main: FinishReached → Sound 'win' + зелёный 'Победа! Ты дошёл до финиша!'

Юзер: открой копию ЗАНОВО на Lua — старый проект 2908 был со старым
кодом (только print), новая копия получит обновлённые скрипты.
This commit is contained in:
min 2026-06-09 10:47:56 +03:00
parent ad26395e10
commit 901c770fdc

View File

@ -132,35 +132,89 @@ end)`,
// ═══════════════════════════════════════════════════════════════
'platform-jump': {
g2_main: `-- === ИГРА «ПРЫГАЙ ПО ПЛАТФОРМАМ» — главный скрипт (Lua) ===
${SNIPPET_BROADCAST}
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local won = false
print("Допрыгай до зелёного финиша!")
-- Подсказка по центру (на 3 секунды)
local hintGui = Instance.new("ScreenGui", player.PlayerGui)
hintGui.Name = "Hint"
local hint = Instance.new("TextLabel", hintGui)
hint.Size = UDim2.new(0, 480, 0, 60)
hint.Position = UDim2.new(0.5, -240, 0.3, 0)
hint.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
hint.BackgroundTransparency = 0.4
hint.TextColor3 = Color3.fromRGB(255, 255, 255)
hint.TextScaled = true
hint.Font = Enum.Font.SourceSansBold
hint.Text = "Допрыгай до зелёной площадки!"
task.delay(3, function() hintGui:Destroy() end)
-- Каждый кадр проверяем не упал ли игрок
-- Звуки
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()
for _, player in ipairs(Players:GetPlayers()) do
local char = player.Character
if char then
local hrp = char:FindFirstChild("HumanoidRootPart")
if hrp and hrp.Position.Y < -10 then
-- Респаун
player:LoadCharacter()
print("Упал! Попробуй ещё раз")
end
end
if won then return end
local char = player.Character
if not char then return end
local hrp = char:FindFirstChild("HumanoidRootPart")
if hrp and hrp.Position.Y < -3 then
player:LoadCharacter()
loseSound:Play()
local fallGui = Instance.new("ScreenGui", player.PlayerGui)
local fallLabel = Instance.new("TextLabel", fallGui)
fallLabel.Size = UDim2.new(0, 400, 0, 60)
fallLabel.Position = UDim2.new(0.5, -200, 0.35, 0)
fallLabel.BackgroundColor3 = Color3.fromRGB(120, 0, 0)
fallLabel.BackgroundTransparency = 0.3
fallLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
fallLabel.TextScaled = true
fallLabel.Font = Enum.Font.SourceSansBold
fallLabel.Text = "Упал! Пробуй снова."
task.delay(1.5, function() fallGui:Destroy() end)
end
end)
-- Финиш-зона шлёт BindableEvent
local finishEvent = getEvent("FinishReached")
finishEvent.Event:Connect(function()
if won then return end
won = true
winSound:Play()
local winGui = Instance.new("ScreenGui", player.PlayerGui)
local winLabel = Instance.new("TextLabel", winGui)
winLabel.Size = UDim2.new(0, 540, 0, 80)
winLabel.Position = UDim2.new(0.5, -270, 0.4, 0)
winLabel.BackgroundColor3 = Color3.fromRGB(0, 120, 0)
winLabel.BackgroundTransparency = 0.2
winLabel.TextColor3 = Color3.fromRGB(255, 255, 0)
winLabel.TextScaled = true
winLabel.Font = Enum.Font.SourceSansBold
winLabel.Text = "Победа! Ты дошёл до финиша!"
end)`,
g2_finish: `-- === Скрипт финишной платформы (Lua) ===
g2_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
print("ПОБЕДА! Ты допрыгал!")
-- Заморозить
h.WalkSpeed = 0
h.JumpPower = 0
fired = true
local ev = ReplicatedStorage:FindFirstChild("FinishReached")
if ev then ev:Fire() end
end)`,
},