feat(lua-games): полный паритет для игры 8 «Беги к финишу»
JS: - ui.timer + showText 'Беги к зелёному финишу — на время!' - onTick: time += dt - onMessage 'finish' → 'Финиш! Время: N сек' + win + confetti - g8_finish: onTouch → broadcast 'finish' Lua (паритет): - ScreenGui+TextLabel секундомер вверху по центру '0.0 сек' - __rbxl_show_text подсказка - RunService.Heartbeat: time += dt → label.Text каждый кадр - BindableEvent FinishReached - g8_finish: Touched → ev:Fire с fired-флагом - При финише: 'Финиш! Твоё время: X.X сек' + win Sound + confetti
This commit is contained in:
parent
1a174f2854
commit
73bf9f5c34
@ -564,18 +564,66 @@ end)`,
|
|||||||
// ИГРА 8 — «Беги до финиша»
|
// ИГРА 8 — «Беги до финиша»
|
||||||
// ═══════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════
|
||||||
'run-to-finish': {
|
'run-to-finish': {
|
||||||
g8_main: `-- === ИГРА «БЕГИ ДО ФИНИША» — главный скрипт (Lua) ===
|
g8_main: `-- === ИГРА «БЕГИ К ФИНИШУ» — главный скрипт (Lua) ===
|
||||||
print("Беги к зелёной плите!")`,
|
${SNIPPET_BROADCAST}
|
||||||
g8_finish: `-- === Финишная плита (Lua) ===
|
|
||||||
|
local Players = game:GetService("Players")
|
||||||
|
local RunService = game:GetService("RunService")
|
||||||
|
local player = Players.LocalPlayer
|
||||||
|
local finished = false
|
||||||
|
local time = 0
|
||||||
|
|
||||||
|
__rbxl_show_text("Беги к зелёному финишу — на время!", 3)
|
||||||
|
|
||||||
|
-- Секундомер вверху по центру
|
||||||
|
local screenGui = Instance.new("ScreenGui", player.PlayerGui)
|
||||||
|
local timerLabel = Instance.new("TextLabel", screenGui)
|
||||||
|
timerLabel.Size = UDim2.new(0, 220, 0, 60)
|
||||||
|
timerLabel.Position = UDim2.new(0.5, -110, 0, 20)
|
||||||
|
timerLabel.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
|
||||||
|
timerLabel.BackgroundTransparency = 0.4
|
||||||
|
timerLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
|
||||||
|
timerLabel.TextScaled = true
|
||||||
|
timerLabel.Font = Enum.Font.SourceSansBold
|
||||||
|
timerLabel.Text = "0.0 сек"
|
||||||
|
|
||||||
|
local winSound = Instance.new("Sound", workspace)
|
||||||
|
winSound.SoundId = "win"; winSound.Volume = 1
|
||||||
|
|
||||||
|
-- Каждый кадр прибавляем dt к таймеру
|
||||||
|
RunService.Heartbeat:Connect(function(dt)
|
||||||
|
if finished then return end
|
||||||
|
time = time + (dt or 0.016)
|
||||||
|
-- Округляем до одного знака для отображения
|
||||||
|
local rounded = math.floor(time * 10) / 10
|
||||||
|
timerLabel.Text = string.format("%.1f сек", rounded)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Финиш-зона шлёт BindableEvent
|
||||||
|
local finishEvent = getEvent("FinishReached")
|
||||||
|
finishEvent.Event:Connect(function()
|
||||||
|
if finished then return end
|
||||||
|
finished = true
|
||||||
|
local t = math.floor(time * 10) / 10
|
||||||
|
winSound:Play()
|
||||||
|
__rbxl_show_text("Финиш! Твоё время: " .. string.format("%.1f", t) .. " сек", 6)
|
||||||
|
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)`,
|
||||||
|
g8_finish: `-- === Скрипт финиша (Lua) ===
|
||||||
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||||
local part = script.Parent
|
local part = script.Parent
|
||||||
local won = false
|
local fired = false
|
||||||
|
|
||||||
part.Touched:Connect(function(hit)
|
part.Touched:Connect(function(hit)
|
||||||
if won then return end
|
if fired then return end
|
||||||
local h = hit.Parent and hit.Parent:FindFirstChild("Humanoid")
|
local h = hit.Parent and hit.Parent:FindFirstChild("Humanoid")
|
||||||
if not h then return end
|
if not h then return end
|
||||||
won = true
|
fired = true
|
||||||
print("ПОБЕДА! Ты добежал!")
|
local ev = ReplicatedStorage:FindFirstChild("FinishReached")
|
||||||
h.WalkSpeed = 0
|
if ev then ev:Fire() end
|
||||||
end)`,
|
end)`,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user