feat: 50 игр на Lua + импорт Roblox для всех + поддержка Lua в плеере #39
@ -917,31 +917,127 @@ end)`;
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
// ИГРА 12 — «Кодовая дверь»
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
'code-door': {
|
||||
g12_main: `-- === ИГРА «КОДОВАЯ ДВЕРЬ» — главный скрипт (Lua) ===
|
||||
'code-door': (function() {
|
||||
const overrides = {
|
||||
g12_main: `-- === ИГРА «ДВЕРЬ ПО КОДУ» — главный скрипт (Lua) ===
|
||||
${SNIPPET_BROADCAST}
|
||||
|
||||
local correctCode = "1234"
|
||||
local currentInput = ""
|
||||
local TweenService = game:GetService("TweenService")
|
||||
local CODE = { 3, 1, 4, 2 }
|
||||
local entered = {}
|
||||
local opened = false
|
||||
local won = false
|
||||
|
||||
print("Введи код 1234 (касайся кнопок по порядку)")
|
||||
__rbxl_show_text("Нажми кнопки в правильном порядке (E)", 4)
|
||||
|
||||
local ev = getEvent("CodeButton")
|
||||
ev.Event:Connect(function(digit)
|
||||
currentInput = currentInput .. tostring(digit)
|
||||
print("Ввод: " .. currentInput)
|
||||
if #currentInput == 4 then
|
||||
if currentInput == correctCode then
|
||||
print("Верно! Дверь открывается")
|
||||
local doorEv = getEvent("DoorOpen")
|
||||
doorEv:Fire()
|
||||
else
|
||||
print("Неверный код, попробуй ещё")
|
||||
end
|
||||
currentInput = ""
|
||||
local clickSound = Instance.new("Sound", workspace)
|
||||
clickSound.SoundId = "click"; clickSound.Volume = 0.7
|
||||
local loseSound = Instance.new("Sound", workspace)
|
||||
loseSound.SoundId = "lose"; loseSound.Volume = 0.8
|
||||
local winSound = Instance.new("Sound", workspace)
|
||||
winSound.SoundId = "win"; winSound.Volume = 1
|
||||
|
||||
local pressEvent = getEvent("ButtonPress")
|
||||
pressEvent.Event:Connect(function(num)
|
||||
if opened then return end
|
||||
clickSound:Play()
|
||||
table.insert(entered, num)
|
||||
local i = #entered
|
||||
if entered[i] ~= CODE[i] then
|
||||
-- ошибка — сброс
|
||||
entered = {}
|
||||
__rbxl_show_text("Неверно! Код сброшен.", 1.5)
|
||||
loseSound:Play()
|
||||
return
|
||||
end
|
||||
if #entered == #CODE then
|
||||
opened = true
|
||||
__rbxl_show_text("Код верный! Дверь открывается.", 3)
|
||||
winSound:Play()
|
||||
local door = workspace:FindFirstChild("Дверь")
|
||||
if door then
|
||||
local dp = door.Position
|
||||
local goal = { Position = Vector3.new(dp.X, dp.Y + 6, dp.Z) }
|
||||
TweenService:Create(door, TweenInfo.new(1.2), goal):Play()
|
||||
door.CanCollide = false
|
||||
end
|
||||
else
|
||||
__rbxl_show_text("Верно! Дальше...", 1)
|
||||
end
|
||||
end)
|
||||
|
||||
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)`,
|
||||
},
|
||||
g12_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)`,
|
||||
};
|
||||
// 4 кнопки — каждая шлёт свой номер при нажатии E (если игрок рядом)
|
||||
for (let num = 1; num <= 4; num++) {
|
||||
overrides['g12_btn_' + num] = `-- === Скрипт кнопки-цифры ${num} (Lua) ===
|
||||
local UserInputService = game:GetService("UserInputService")
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local RunService = game:GetService("RunService")
|
||||
local part = script.Parent
|
||||
local hintVisible = false
|
||||
|
||||
-- Подсказка над кнопкой (виден когда игрок рядом)
|
||||
local hintGui = Instance.new("BillboardGui", part)
|
||||
hintGui.Size = UDim2.new(4, 0, 1, 0)
|
||||
hintGui.StudsOffset = Vector3.new(0, 1.5, 0)
|
||||
hintGui.AlwaysOnTop = true
|
||||
local label = Instance.new("TextLabel", hintGui)
|
||||
label.Size = UDim2.new(1, 0, 1, 0)
|
||||
label.BackgroundTransparency = 1
|
||||
label.TextColor3 = Color3.fromRGB(255, 255, 255)
|
||||
label.TextStrokeTransparency = 0
|
||||
label.TextScaled = true
|
||||
label.Text = "[E] Нажать ${num}"
|
||||
label.Visible = false
|
||||
|
||||
-- Каждый кадр проверяем дистанцию до игрока
|
||||
RunService.Heartbeat:Connect(function()
|
||||
local px = __rbxl_player_x()
|
||||
local pz = __rbxl_player_z()
|
||||
local dx = part.Position.X - px
|
||||
local dz = part.Position.Z - pz
|
||||
local dist = math.sqrt(dx*dx + dz*dz)
|
||||
local near = dist <= 3
|
||||
if near ~= hintVisible then
|
||||
hintVisible = near
|
||||
label.Visible = near
|
||||
end
|
||||
end)
|
||||
|
||||
UserInputService.InputBegan:Connect(function(input, gp)
|
||||
if gp then return end
|
||||
if not hintVisible then return end
|
||||
if input.KeyCode ~= Enum.KeyCode.E then return end
|
||||
local ev = ReplicatedStorage:FindFirstChild("ButtonPress")
|
||||
if ev then ev:Fire(${num}) end
|
||||
end)`;
|
||||
}
|
||||
return overrides;
|
||||
})(),
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
// ИГРА 13 — «Торговец»
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user