feat: 50 игр на Lua + импорт Roblox для всех + поддержка Lua в плеере #39

Merged
min merged 215 commits from feat/lua-50-games-bundle into main 2026-06-09 21:59:25 +00:00
Showing only changes of commit bec3c478e7 - Show all commits

View File

@ -632,41 +632,89 @@ end)`,
// ═══════════════════════════════════════════════════════════════
'traffic-light': {
g9_main: `-- === ИГРА «СВЕТОФОР» — главный скрипт (Lua) ===
${SNIPPET_BROADCAST}
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local won = false
local phase = "green" -- "green" (беги) или "red" (замри)
local phaseTimer = 0
local GREEN_TIME = 3
local RED_TIME = 2.5
local isGreen = true
print("ЗЕЛЁНЫЙ — беги!")
__rbxl_show_text("Зелёный — беги! Красный — замри!", 3)
-- Каждые 3-5 сек переключаем свет
task.spawn(function()
while true do
task.wait(math.random(3, 5))
isGreen = not isGreen
if isGreen then
print("ЗЕЛЁНЫЙ — беги!")
else
print("КРАСНЫЙ — стой!")
local loseSound = Instance.new("Sound", workspace)
loseSound.SoundId = "lose"; loseSound.Volume = 1
local winSound = Instance.new("Sound", workspace)
winSound.SoundId = "win"; winSound.Volume = 1
-- Находим светофор и сразу красим в зелёный
local light = workspace:FindFirstChild("Светофор")
if light then light.Color = Color3.fromRGB(34, 221, 85) end
__rbxl_show_text("ЗЕЛЁНЫЙ — беги!", 1.2)
-- Каждый кадр считаем таймер фазы и проверяем движение
local prevX, prevZ = nil, nil
RunService.Heartbeat:Connect(function(dt)
if won then return end
dt = dt or 0.016
-- Переключение фаз
phaseTimer = phaseTimer + dt
if phase == "green" and phaseTimer >= GREEN_TIME then
phaseTimer = 0
phase = "red"
if light then light.Color = Color3.fromRGB(226, 59, 59) end
__rbxl_show_text("КРАСНЫЙ — замри!", 1.2)
elseif phase == "red" and phaseTimer >= RED_TIME then
phaseTimer = 0
phase = "green"
if light then light.Color = Color3.fromRGB(34, 221, 85) end
__rbxl_show_text("ЗЕЛЁНЫЙ — беги!", 1.2)
end
-- Если красный и игрок шевелится респаун
local px = __rbxl_player_x()
local pz = __rbxl_player_z()
if prevX and phase == "red" then
local dx = px - prevX
local dz = pz - prevZ
local moved = math.sqrt(dx*dx + dz*dz)
if moved / dt > 0.8 then
player:LoadCharacter()
loseSound:Play()
__rbxl_show_text("Двинулся на красный! На старт.", 2)
end
end
prevX, prevZ = px, pz
end)
-- Следим за движением игрока во время красного
local lastPos = {}
RunService.Heartbeat:Connect(function()
if isGreen then return end
for _, player in ipairs(Players:GetPlayers()) do
local char = player.Character
local hrp = char and char:FindFirstChild("HumanoidRootPart")
if hrp then
local prev = lastPos[player]
if prev and (hrp.Position - prev).Magnitude > 0.5 then
print(player.Name .. " двигался на красный! Респаун")
player:LoadCharacter()
end
lastPos[player] = hrp.Position
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)`,
g9_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)`,
},